Skip to content

Add files via upload#26

Open
slavikpas wants to merge 1 commit into
mainfrom
slavikpas-patch-15
Open

Add files via upload#26
slavikpas wants to merge 1 commit into
mainfrom
slavikpas-patch-15

Conversation

@slavikpas
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prisma Cloud has found errors in this PR ⬇️

Comment thread slavikTestSastCWE327.java
protected void engineReset() {
// Implementation details
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM  Unsafe custom MessageDigest is implemented
    File: slavikTestSastCWE327.java | Checkov ID: CKV3_SAST_13

Description

CWE: CWE-327: Use of a Broken or Risky Cryptographic Algorithm
OWASP: A02:2021-Cryptographic Failures

Flag any custom classes that extend the java.security.MessageDigest class. MessageDigest is a Java class used for calculating message digests, also known as checksums or cryptographic hash functions. By extending MessageDigest, a developer could be creating a custom cryptographic hash function, which is generally considered error-prone and a bad practice.

Cryptography is a complex field and implementing a secure and reliable cryptographic hash function requires specific expertise. Improperly implemented hash functions can have vulnerabilities that can be exploited, leading to significant security risks.

Example of violating code:

import java.security.MessageDigest;

public class CustomDigest extends MessageDigest {
    public CustomDigest() {
        super("CustomDigest");
    }

    // ... custom implementation ...
}

In the example above, a custom MessageDigest is being created, which would be flagged.

Comment thread slavik.py
@@ -0,0 +1,19 @@
assert()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM  Improper handling of checking for unusual or exceptional conditions
    File: slavik.py | Checkov ID: CKV3_SAST_4

Description

CWE: CWE-754: Improper Check for Unusual or Exceptional Conditions

The assert statement in Python is used for debugging purposes. It lets you test if a certain condition is met, and if not, the program will raise an AssertionError exception.

The main problem with assert is that it can be globally disabled with the -O (optimize) option in Python, or by setting the environment variable PYTHONOPTIMIZE to a non-empty string. This means that when Python code is run in optimized mode, all assert statements are ignored.

Therefore, if you're using assert to check for conditions that should prevent the program from continuing (for example, validating user input or checking configuration files), those checks will be skipped in optimized mode, which could lead to incorrect program behavior or even security vulnerabilities.

Here is an example of problematic code:

def process_data(data):
    assert data is not None, "Data must not be None"
    # Continue with processing...

In this code, if Python is run with optimization enabled, the assert statement will be ignored, and the process_data function will proceed even if data is None, which could cause errors later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant