UNPKG

mcp-server-semgrep

Version:

MCP Server for Semgrep Integration - static code analysis with AI

63 lines (62 loc) 1.91 kB
rules: - id: bad-deserialization-yaml patterns: - pattern: | YAML.load($...ARGS) - pattern-not: | YAML.load(..., safe: true, ...) - pattern-not: | YAML.load("...", ...) - pattern-not-inside: | YAML.load(..., File.read(...), ...) - pattern-not-inside: | $FILE = File.read(...) ... YAML.load(..., $FILE, ...) - pattern-not-inside: | $FILENAME = ... ... $FILE = File.read($FILENAME, ...) ... YAML.load(..., $FILE, ...) - pattern-not-inside: | YAML.load(..., $X.$Y(File.read(...)), ...) - pattern-not-inside: | YAML.load(..., $X.$Y(File.read(...)).$Z, ...) - pattern-not-inside: | $T = $MOD.$MET(File.read(...)) ... YAML.load(..., $T, ...) - pattern-not-inside: | $T = $MOD.$MET(File.read(...)) ... YAML.load(..., $T.$R, ...) fix: Psych.safe_load($...ARGS) message: >- Unsafe deserialization from YAML. Objects in Ruby can be serialized into strings, then later loaded from strings. However, uses of load and object_load can cause remote code execution. Loading user input with YAML can potentially be dangerous. Use JSON in a secure fashion instead. However, loading YAML from a static file is not dangerous and should not be flagged. metadata: cwe: - 'CWE-502: Deserialization of Untrusted Data' references: - https://groups.google.com/g/rubyonrails-security/c/61bkgvnSGTQ/m/nehwjA8tQ8EJ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_deserialize.rb category: security technology: - ruby - yaml owasp: - A08:2017 - Insecure Deserialization - A08:2021 - Software and Data Integrity Failures cwe2022-top25: true cwe2021-top25: true subcategory: - audit likelihood: LOW impact: HIGH confidence: LOW languages: - ruby severity: ERROR