UNPKG

mcp-server-semgrep

Version:

MCP Server for Semgrep Integration - static code analysis with AI

74 lines (73 loc) 2.71 kB
rules: - id: tainted-cmd-from-http-request message: >- Detected input from a HTTPServletRequest going into a 'ProcessBuilder' or 'exec' command. This could lead to command injection if variables passed into the exec commands are not properly sanitized. Instead, avoid using these OS commands with user-supplied input, or, if you must use these commands, use a whitelist of specific values. languages: [java] severity: ERROR mode: taint pattern-sources: - patterns: - pattern-either: - pattern: | (HttpServletRequest $REQ) - patterns: # this pattern is a hack to get the rule to recognize `map` as tainted source when `cookie.getValue(user_input)` is used. - pattern-inside: | (javax.servlet.http.Cookie[] $COOKIES) = (HttpServletRequest $REQ).getCookies(...); ... for (javax.servlet.http.Cookie $COOKIE: $COOKIES) { ... } - pattern: | $COOKIE.getValue(...) pattern-sinks: - patterns: - pattern-either: - pattern: | (ProcessBuilder $PB) = ...; - patterns: - pattern: | (Process $P) = ...; - pattern-not: | (Process $P) = (java.lang.Runtime $R).exec(...); - patterns: - pattern: (java.lang.Runtime $R).exec($CMD, ...); - focus-metavariable: $CMD - patterns: - pattern-either: - pattern-inside: | (java.util.List<$TYPE> $ARGLIST) = ...; ... (ProcessBuilder $PB) = ...; ... $PB.command($ARGLIST); - pattern-inside: | (java.util.List<$TYPE> $ARGLIST) = ...; ... (ProcessBuilder $PB) = ...; - pattern-inside: | (java.util.List<$TYPE> $ARGLIST) = ...; ... (Process $P) = ...; - pattern: | $ARGLIST.add(...); metadata: category: security technology: - java cwe: - "CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')" owasp: - A01:2017 - Injection - A03:2021 - Injection references: - https://owasp.org/Top10/A03_2021-Injection cwe2022-top25: true cwe2021-top25: true subcategory: - vuln likelihood: MEDIUM impact: MEDIUM confidence: MEDIUM