Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/ruleset no backticks in js handlers #292

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions assets/semgrep_rules/web/no-backticks-in-js-handlers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rules:
- id: no-backticks-in-js-handlers
patterns:
- pattern-either:
- pattern-inside: $HANDLER="..."
- pattern-inside: $HANDLER='...'
- pattern-inside: $HANDLER=...
thypon marked this conversation as resolved.
Show resolved Hide resolved
- pattern-regex: '`{{[^}]+}}`'
- metavariable-regex:
metavariable: $HANDLER
regex: on(abort|auxclick|beforeinput|beforematch|beforetoggle|cancel|canplay|canplaythrough|change|click|close|contextlost|contextmenu|contextrestored|copy|cuechange|cut|dblclick|drag|dragend|dragenter|dragleave|dragover|dragstart|drop|durationchange|emptied|ended|formdata|input|invalid|keydown|keypress|keyup|loadeddata|loadedmetadata|loadstart|mousedown|mouseenter|mouseleave|mousemove|mouseout|mouseover|mouseup|paste|pause|play|playing|progress|ratechange|reset|securitypolicyviolation|seeked|seeking|select|slotchange|stalled|submit|suspend|timeupdate|toggle|volumechange|waiting|webkitAnimationEnd|webkitAnimationIteration|webkitAnimationStart|webkitTransitionEnd|wheel)
thypon marked this conversation as resolved.
Show resolved Hide resolved
message: |
Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.

Consider using single or double apices, instead of backticks.
languages: [generic]
severity: WARNING
6 changes: 6 additions & 0 deletions t3sts/semgrep_rules/no-backticks-in-js-handlers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ruleid: no-backticks-in-js-handlers
onclick="call('good', `{{var}}`, `{{var}}`)"

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.

Consider using single or double apices, instead of backticks.


Source: https://github.com/brave/security-action


Cc @thypon @bcaller

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL

In written Latin, the apex (plural "apices") is a mark with roughly the shape of an acute accent ◌́ which was sometimes placed over vowels to indicate that they are long.

Copy link
Member Author

Choose a reason for hiding this comment

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

now you know what they mean by "apex twins" :P

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.

Consider using single or double apices, instead of backticks.


Source: https://github.com/brave/security-action


Cc @thypon @bcaller

// ruleid: no-backticks-in-js-handlers
onclick='call("good", `{{var}}`, `{{var}}`)'

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.

Consider using single or double apices, instead of backticks.


Source: https://github.com/brave/security-action


Cc @thypon @bcaller

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.

Consider using single or double apices, instead of backticks.


Source: https://github.com/brave/security-action


Cc @thypon @bcaller

// ruleid: no-backticks-in-js-handlers
onclick=call('good', `{{var}}`, `{{var}}`)

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.

Consider using single or double apices, instead of backticks.


Source: https://github.com/brave/security-action


Cc @thypon @bcaller

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.

Consider using single or double apices, instead of backticks.


Source: https://github.com/brave/security-action


Cc @thypon @bcaller

Loading