Skip to content

Conversation

@nnayar-r2c
Copy link
Contributor

No description provided.

ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
ELContext elContext = context.getELContext();
// deepid: tainted-code-injection-from-http-request
ValueExpression vex = expressionFactory.createValueExpression(elContext, expression, String.class);

Choose a reason for hiding this comment

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

Passing unsanitized user input to a Script Engine or other means of dynamic code evaluation is unsafe. This could lead to code injection with data leakage or arbitrary code execution as a result. Avoid this, or use proper sandboxing if user code evaluation is intended.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>injection.java</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] request.getHeader(&quot;BenchmarkTest00006&quot;)</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] param</a>"]

            v3["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L54 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 54] evaluateExpression</a>"]

            v4["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L62 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 62] expression</a>"]
        end
            v2 --> v3
            v3 --> v4
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L67 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 67] expressionFactory.createValueExpression(elContext, expression, String.class)</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from tainted-code-injection-from-http-request.

Choose a reason for hiding this comment

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

Semgrep Assistant thinks you might be able to fix the finding like this:

Suggested change
ValueExpression vex = expressionFactory.createValueExpression(elContext, expression, String.class);
// Sanitize the input expression before creating a ValueExpression to mitigate code injection risks.
// Implement a dedicated method or use a library to adequately sanitize the input based on the application's context.
String sanitizedExpression = sanitizeExpression(expression); // This is a placeholder. Actual implementation of sanitizeExpression() is required.
ValueExpression vex = expressionFactory.createValueExpression(elContext, sanitizedExpression, String.class);

The proposed fix suggests sanitizing the input expression before using it to mitigate code injection risks. While the suggestion to sanitize input is a valid and important security measure, the code provided does not include an actual implementation of the sanitizeExpression method, indicating that without further code development, the issue may still persist. Additionally, since the sanitizeExpression method is referred to but not defined anywhere in the provided fix, implementing this suggestion would require additional code changes to either define sanitizeExpression within the current scope or reference an existing implementation from elsewhere in the codebase.

AI-generated comment. Please review the code carefully.

ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
ELContext elContext = context.getELContext();
//ruleid: tainted-code-injection-from-http-request
ValueExpression vex = expressionFactory.createValueExpression(elContext, "expression" + param, String.class);

Choose a reason for hiding this comment

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

Passing unsanitized user input to a Script Engine or other means of dynamic code evaluation is unsafe. This could lead to code injection with data leakage or arbitrary code execution as a result. Avoid this, or use proper sandboxing if user code evaluation is intended.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>injection.java</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] request.getHeader(&quot;BenchmarkTest00006&quot;)</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] param</a>"]
        end
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L52 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 52] expressionFactory.createValueExpression(elContext, &quot;expression&quot; + param, String.class)</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from tainted-code-injection-from-http-request.

Choose a reason for hiding this comment

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

Semgrep Assistant thinks you might be able to fix the finding like this:

Suggested change
ValueExpression vex = expressionFactory.createValueExpression(elContext, "expression" + param, String.class);
// Ensure the user input 'param' is properly sanitized before incorporating it into the expression
String sanitizedParam = org.apache.commons.lang3.StringEscapeUtils.escapeEcmaScript(param);
ValueExpression vex = expressionFactory.createValueExpression(elContext, "expression" + sanitizedParam, String.class);

AI-generated comment. Please review the code carefully.

String script = createTaintedScript(param);

//ruleid: tainted-code-injection-from-http-request
engine.eval(script); //Bad things can happen here.

Choose a reason for hiding this comment

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

Passing unsanitized user input to a Script Engine or other means of dynamic code evaluation is unsafe. This could lead to code injection with data leakage or arbitrary code execution as a result. Avoid this, or use proper sandboxing if user code evaluation is intended.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>injection.java</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] request.getHeader(&quot;BenchmarkTest00006&quot;)</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L39 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 39] script</a>"]

            v3["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L58 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 58] param</a>"]

            v4["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L39 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 39] createTaintedScript</a>"]

            v5["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] param</a>"]
        end
            v2 --> v3
            v3 --> v4
            v4 --> v5
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L42 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 42] engine.eval(script)</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from tainted-code-injection-from-http-request.

Choose a reason for hiding this comment

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

Semgrep Assistant thinks you might be able to fix the finding like this:

Suggested change
engine.eval(script); //Bad things can happen here.
// To mitigate the risk of code injection, sanitize the input script before evaluation.
// Here, assuming `sanitizeScript` is a method that effectively neutralizes any potential harmful
// code within the user input. Implement such a method accordingly to your context.
// If implementing a sanitizer is not feasible or reliable, consider fully disallowing dynamic script execution.
String sanitizedScript = sanitizeScript(script);
engine.eval(sanitizedScript); // Prevented unsafe script execution by sanitizing input.

The suggested fix introduces a method call to 'sanitizeScript', which is assumed to sanitize the input script to mitigate the risk of code injection. However, the implementation details of 'sanitizeScript' are not provided, and it is noted that this method needs to be accurately implemented to neutralize any potential harm. This suggests that additional code changes are highly likely to implement or integrate the 'sanitizeScript' method effectively within the current codebase. Furthermore, there's a minimal risk that sanitizing may not fully neutralize all forms of harmful input, hence the slight possibility that the original issue might still be present if 'sanitizeScript' does not cover all attack vectors.

AI-generated comment. Please review the code carefully.

ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
ELContext elContext = context.getELContext();
// deepid: tainted-code-injection-from-http-request
ValueExpression vex = expressionFactory.createValueExpression(elContext, expression, String.class);

Choose a reason for hiding this comment

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

Passing unsanitized user input to a Script Engine or other means of dynamic code evaluation is unsafe. This could lead to code injection with data leakage or arbitrary code execution as a result. Avoid this, or use proper sandboxing if user code evaluation is intended.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>injection.java</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] request.getHeader(&quot;BenchmarkTest00006&quot;)</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] param</a>"]

            v3["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L54 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 54] evaluateExpression</a>"]

            v4["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L62 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 62] expression</a>"]
        end
            v2 --> v3
            v3 --> v4
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L67 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 67] expression</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from tainted-code-injection-from-http-request-deepsemgrep.

Choose a reason for hiding this comment

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

Semgrep Assistant thinks you might be able to fix the finding like this:

Suggested change
ValueExpression vex = expressionFactory.createValueExpression(elContext, expression, String.class);
// To mitigate the risk of code injection, the input expression is sanitized before evaluation.
// This basic sanitation simply escapes EL expressions. For a more robust solution,
// consider a stronger validation or whitelisting mechanism.
String sanitizedExpression = expression.replace("#{", "").replace("${", "");
ValueExpression vex = expressionFactory.createValueExpression(elContext, sanitizedExpression, String.class);

The suggested fix attempts to mitigate the risk of code injection by sanitizing the input expression. While this approach helps by removing instances of '#{...}' and '${...}', which are indicators of EL expressions that could be exploited, it does not entirely eliminate the potential for code injection. An attacker could still find ways to bypass this basic sanitation by using other input patterns that achieve the same or similar execution effects. For total mitigation, a more robust solution involving validation against a whitelist, comprehensive input encoding or the use of security libraries designed to counter these risks might be necessary. The concern here is that while the immediate vectors for injection are addressed, the underlying issue of executing untrusted input remains partially unresolved, potentially leaving room for more sophisticated exploits.

AI-generated comment. Please review the code carefully.

ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
ELContext elContext = context.getELContext();
//ruleid: tainted-code-injection-from-http-request
ValueExpression vex = expressionFactory.createValueExpression(elContext, "expression" + param, String.class);

Choose a reason for hiding this comment

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

Passing unsanitized user input to a Script Engine or other means of dynamic code evaluation is unsafe. This could lead to code injection with data leakage or arbitrary code execution as a result. Avoid this, or use proper sandboxing if user code evaluation is intended.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>injection.java</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] request.getHeader(&quot;BenchmarkTest00006&quot;)</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] param</a>"]
        end
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L52 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 52] &quot;expression&quot; + param</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from tainted-code-injection-from-http-request-deepsemgrep.

Choose a reason for hiding this comment

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

Semgrep Assistant thinks you might be able to fix the finding like this:

Suggested change
ValueExpression vex = expressionFactory.createValueExpression(elContext, "expression" + param, String.class);
// Sanitize the user input before incorporating it into the script
String sanitizedParam = ESAPI.encoder().canonicalize(param);
sanitizedParam = sanitizedParam.replaceAll("[^a-zA-Z0-9]", "");
ValueExpression vex = expressionFactory.createValueExpression(elContext, "expression" + sanitizedParam, String.class);

The suggested fix appears to directly address the issue by sanitizing user input, which effectively mitigates the risk of code injection from HTTP request parameters. However, there's a slight chance that other parts of the codebase, not shown in the context provided, may also handle user input in a way that could reintroduce similar vulnerabilities. Without the visibility into the entire codebase, it's prudent to consider a small likelihood that additional changes might be necessary to ensure comprehensive protection against tainted code injection.

AI-generated comment. Please review the code carefully.

String script = createTaintedScript(param);

//ruleid: tainted-code-injection-from-http-request
engine.eval(script); //Bad things can happen here.

Choose a reason for hiding this comment

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

Passing unsanitized user input to a Script Engine or other means of dynamic code evaluation is unsafe. This could lead to code injection with data leakage or arbitrary code execution as a result. Avoid this, or use proper sandboxing if user code evaluation is intended.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>injection.java</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] request.getHeader(&quot;BenchmarkTest00006&quot;)</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L39 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 39] script</a>"]

            v3["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L58 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 58] param</a>"]

            v4["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L39 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 39] createTaintedScript</a>"]

            v5["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L30 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 30] param</a>"]
        end
            v2 --> v3
            v3 --> v4
            v4 --> v5
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/injection.java#L42 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 42] script</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from tainted-code-injection-from-http-request-deepsemgrep.

Choose a reason for hiding this comment

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

Semgrep Assistant thinks you might be able to fix the finding like this:

Suggested change
engine.eval(script); //Bad things can happen here.
// To address the security issue, it's crucial to validate or sanitize the user-provided script before execution.
// Since this code directly relates to the execution of potentially malicious user input, an immediate fix involves
// adding input validation, sanitization, or employing a secure sandbox if user script execution is an absolute requirement.
// However, without specific context on the allowed scripting use cases, the safest approach is to avoid direct execution.
// For demonstration, a basic sanitization placeholder is shown below. Implement genuine validation/sanitization as needed.
// Example basic sanitization (to be replaced with actual logic tailored to the use case):
if (isValidScript(script)) {
engine.eval(script); // Execute the script if it passes validation
} else {
// Handle invalid script case, e.g., log an error, throw an exception, etc.
}
// Note: isValidScript is a hypothetical method that should be implemented to perform actual script validation
// based on the application's requirements and the scripting capabilities intended to be exposed to the user.

The proposed suggestion introduces a process to validate or sanitize the input script, potentially mitigating the issue of executing tainted JavaScript code from an HTTP request. However, since the actual validation logic (e.g., the isValidScript method) is not implemented within the suggestion, adopting this approach necessitates changes elsewhere in the code to define the isValidScript method or any relevant validation/sanitization mechanisms. Specifically, developers will need to implement and carefully design the script validation logic to effectively address the underlying security issue without inadvertently introducing new vulnerabilities. This required addition of validation functionality is why the need for code changes scored relatively high.

AI-generated comment. Please review the code carefully.

@semgrep-code-r2c-cse
Copy link

Semgrep found 1 ssc-f81fb526-8a62-4b49-a50c-82e2e14c7a87 finding:

Risk: certifi versions >= 2015.04.28 before 2023.07.22 are vulnerable to Insufficient Verification Of Data Authenticity. These versions use E-Tugra as a Certificate Authority, which is not recommended due to critical security vulnerabilities, such as the usage of default credentials in administrative tools, re-issuance of certificates without proper validation, and unauthorized access to sensitive information.

Fix: Upgrade this library to at least version 2023.7.22 at bad-python-app/requirements.txt:1.

Reference(s): GHSA-xqr8-7jwr-rhp7, CVE-2023-37920

Ignore this finding from ssc-f81fb526-8a62-4b49-a50c-82e2e14c7a87.

Semgrep found 1 ssc-162a0ce0-3e68-4f2e-bfac-094ede202ccf finding:

Risk: flask versions before 2.2.5, and versions >= 2.3.0 before 2.3.2 are vulnerable to Use Of Persistent Cookies Containing Sensitive Information. This is due to Flask only setting the Vary: Cookie header when the session is accessed or modified, not when it is refreshed (re-sent to update the expiration) without being accessed or modified.

Manual Review Advice: A vulnerability from this advisory is reachable if you have a user-facing instance of flask and meet ALL of the following conditions 1. Hosting an application behind a caching proxy that does not strip cookies or ignore responses with cookies 2. The application sets session.permanent = True 3. The application does not access or modify the session at any point during a request 4. SESSION_REFRESH_EACH_REQUEST is enabled (default) 5. The application does not set a Cache-Control header to indicate that a page is private or should not be cached

Fix: Upgrade this library to at least version 2.2.5 at bad-python-app/requirements.txt:4.

Reference(s): GHSA-m2qf-hxjv-5gpq, CVE-2023-30861

Ignore this finding from ssc-162a0ce0-3e68-4f2e-bfac-094ede202ccf.

@semgrep-code-r2c-cse
Copy link

Semgrep found 2 avoid_print_python_rule findings:

Semgrep found a match

Ignore this finding from avoid_print_python_rule.

Semgrep found 2 dangerous-system-call findings:

Found user-controlled data used in a system call. This could allow a malicious actor to execute commands. Use the 'subprocess' module instead, which is easier to use without accidentally exposing a command injection vulnerability.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>vulns/file_upload/file_upload.py</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L15 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 15] request.files[&apos;file&apos;]</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L15 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 15] file</a>"]

            v3["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L24 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 24] _save_temp_file</a>"]

            v4["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L41 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 41] file</a>"]

            v5["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L42 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 42] original_file_name</a>"]

            v6["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L43 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 43] temp_upload_file_path</a>"]

            v7["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L48 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 48] command</a>"]
        end
            v2 --> v3
            v3 --> v4
            v4 --> v5
            v5 --> v6
            v6 --> v7
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vulns/file_upload/file_upload.py#L49 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 49] os.system(command)</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from dangerous-system-call.

Semgrep found 1 dangerous-os-exec finding:

Found user controlled content when spawning a process. This is dangerous because it allows a malicious actor to execute commands.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>vuln-1.py</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vuln-1.py#L8 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 8] route_param</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vuln-1.py#L8 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 8] route_param</a>"]
        end
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/r2c-CSE/bad-python-app/blob/07e4ea68d7bcd018d1a8079c33ef27c4e59793b8/vuln-1.py#L11 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 11] route_param</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
Ignore this finding from dangerous-os-exec.

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.

2 participants