-
Notifications
You must be signed in to change notification settings - Fork 19
CWE-95 + frontend/template XSS precision #73
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
acde89a
CWE-95 + frontend/template XSS precision
leenk7991 03d8a4f
Fix HTML-only scans so Django |safe rules actually run.
leenk7991 258b9c0
Flag vm.runIn* and string timers as CWE-95, not escapeHtml helpers.
leenk7991 c2290eb
address comment
leenk7991 78045cb
handle iife and quality comment
leenk7991 f8e0bf9
Merge branch 'main' into feat/cwe95-xss-sink-precision
leenk7991 c3383dc
address comments
leenk7991 ee4e724
update django rule pattern and regex and other updates
leenk7991 0f006af
fix: keep PathBuf rebuild walk and pass clippy
leenk7991 1ef0541
add language scopes
leenk7991 ff72b24
address comments
leenk7991 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| fn main() { | ||
| emit_rerun("rules"); | ||
| } | ||
|
|
||
| fn emit_rerun(root: &str) { | ||
| let mut pending = vec![std::path::PathBuf::from(root)]; | ||
| while let Some(path) = pending.pop() { | ||
| println!("cargo:rerun-if-changed={}", path.display()); | ||
| let entries = std::fs::read_dir(&path).unwrap_or_else(|error| { | ||
| panic!("failed to read directory '{}': {error}", path.display()) | ||
| }); | ||
| for entry in entries { | ||
| let entry = entry.unwrap_or_else(|error| { | ||
| panic!("failed to read directory entry in '{}': {error}", path.display()) | ||
| }); | ||
| let child = entry.path(); | ||
| if child.is_dir() { | ||
| pending.push(child); | ||
| } else { | ||
| println!("cargo:rerun-if-changed={}", child.display()); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ( | ||
| rules: [ | ||
| // Autoescaped `{{ var }}` is not XSS. Flag `|safe`/`|mark_safe` only on | ||
| // request data inside one `{{ ... }}` (`[^}]*` cannot join adjacent | ||
| // expressions). Dummy `=` names pass the `|safe` / `|mark_safe` / `{{` | ||
| // call-name prefilter (`django-{{=` contains `{{` but is not template | ||
| // syntax). Spaced filters (`| safe`) resolve as `{{`. | ||
| ( | ||
| id: Some("html-django-safe-request-xss"), | ||
| name: Some("Django |safe on request data"), | ||
| category: Some("xss"), | ||
| mode: "search", | ||
| patterns: Some([ | ||
| "django-safe-filter-sink=", | ||
| "|safe=", | ||
| "|mark_safe=", | ||
| "django-{{=", | ||
| "regex:\\{\\{[^}]*request\\.(GET|POST|COOKIES)[^}]*\\|\\s*(mark_)?safe[^}]*\\}\\}" | ||
| ]), | ||
| finding_type: Some("Cross-Site Scripting"), | ||
| severity: Some("High"), | ||
| confidence: Some("High"), | ||
| cwe_id: Some("cwe-79"), | ||
| description: Some("Request data passed through |safe / |mark_safe disables autoescape and is reflected XSS"), | ||
| file_types: Some(( | ||
| extensions: Some([".html", ".htm"]) | ||
| )), | ||
| tags: Some(["xss", "django", "cwe-79"]) | ||
| ) | ||
| ] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.