Skip to content

Instantly share code, notes, and snippets.

@minusworld
Created July 8, 2021 22:55
Show Gist options
  • Save minusworld/968d229f81b9048b80aaa783cd1fe228 to your computer and use it in GitHub Desktop.
Save minusworld/968d229f81b9048b80aaa783cd1fe228 to your computer and use it in GitHub Desktop.
rules:
- id: user-input-escaped-with-safe
mode: join
join:
refs:
- rule: https://raw.githubusercontent.com/minusworld/semgrep-library/main/rules/flask/flask-user-input.yaml
as: user-input
- rule: https://raw.githubusercontent.com/minusworld/semgrep-library/main/rules/flask/render-template-input.yaml
as: render-template-input
- rule: https://raw.githubusercontent.com/minusworld/semgrep-library/main/rules/flask/template-var-safe.yaml
renames:
- from: '$...EXPR'
to: '$VAR'
as: template-vars
on:
- 'user-input.$VAR == render-template-input.$INPUT'
- 'render-template-input.$VAR == template-vars.$VAR'
- 'render-template-input.$TEMPLATE ~ template-vars.path'
message: >-
The variable '$VAR' is most likely an XSS. It originates as user input
and is unsafely rendered with the '| safe' filter.
severity: ERROR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment