Repository navigation
[Query Fix - githubsecuritylab/rust/iron-response-xss] - find Iron response XSS when the prelude calls have no target - #264
Merged
Conversation
A database that is built without compiling the code leaves every call that goes through a glob import of the iron prelude without a target. The Iron data extension rows and the sink that matches the canonical path of Response::with then do not apply, and githubsecuritylab/rust/iron-response-xss found nothing in code that starts with use iron::prelude::*. Recognize the API by its names for those calls, in files that use iron: a function or closure with a Request parameter is a source, the fields of the request and the method calls that have no target pass the data on, and a call of Response::with that has no target is a sink (a body on its own as well). A handler that the modelled source already reaches is reported once. Add a test file that has only the glob import, a test that lists its calls that have no target, a file with the same names from another framework that must not alert, and negative cases (constant body, length only, text/plain, encoded, sanitized, a parameter that is not a request). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical XSS false negatives remain because the fallback treats non-HTML escaping methods as safe and misses resolved body-only response sinks in unregistered handlers.
2 open issues
What changed in this PR
This PR extends the Rust Iron response XSS query to detect unsafe responses when prelude imports leave API calls unresolved, while preserving existing resolved-call detection.
Changes:
- Adds name-based fallback sources, flow steps, and response sinks for files using Iron.
- Adds regression fixtures for unresolved calls, safe responses, other frameworks, and unregistered handlers.
- Documents fallback behavior and limitations.
| File | Description |
|---|---|
rust/test/security/CWE-079/IronResponseXss/other_framework.rs |
Checks that similarly named non-Iron APIs are excluded. |
rust/test/security/CWE-079/IronResponseXss/main.rs |
Adds an unregistered-handler fixture. |
rust/test/security/CWE-079/IronResponseXss/IronResponseXss.expected |
Records additional alerts and flow paths. |
rust/test/security/CWE-079/IronResponseXss/IronModels.expected |
Adds the new handler’s modeled sink. |
rust/test/security/CWE-079/IronResponseXss/GlobCalls.ql |
Checks that the glob-import fixture retains unresolved calls. |
rust/test/security/CWE-079/IronResponseXss/GlobCalls.expected |
Records expected unresolved calls. |
rust/test/security/CWE-079/IronResponseXss/glob_prelude.rs |
Adds fallback detection and exclusion fixtures. |
rust/src/security/CWE-079/IronResponseXss.ql |
Integrates fallback analysis and suppresses overlapping source reports. |
rust/src/security/CWE-079/IronResponseXss.qhelp |
Describes fallback coverage and limitations. |
rust/src/common/IronFallback.qll |
Defines name-based Iron recognition and flow predicates. |
Review effort: Balanced
…ody-only handlers Two review findings on the fallback. A method whose name only contains escape or encode was taken to encode for HTML, which hid the taint of escape_default (it keeps markup) and of unescape_html. Only names that say HTML (escape_html, html_escape, encode_html) are taken to encode now. escape_default is an alert in the glob-only fixture, and a method that says escape_html is the safe form. A body that is passed on its own to a call of Response::with that resolves was reported only through the data extension sink, which needs a handler that Iron::new or Chain::new registers. A handler that nothing registers has no modelled source, so the flow was missed. Add the sink for the flows from the request parameter, and leave the flows of modelled sources to the standard query. Add the regression in main.rs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical filtering flaw can suppress both queries’ results for a vulnerability when a flow passes through an unresolved intermediate method; suppression must depend on actual standard-analysis reachability and be covered by a regression test.
1 open issue
2 resolved since last review
Review effort: Balanced
Comment on lines
+207
to
+208
| sinkNode.getNode() instanceof IronResolvedResponseBody and | ||
| sourceNode.getNode() instanceof Xss::Source |
felickz
marked this pull request as ready for review
November 26, 2026 06:19
felickz
added a commit
that referenced
this pull request
Nov 26, 2026
…sponse XSS when the prelude calls have no target (#264) * Rust: find Iron response XSS when the prelude calls have no target A database that is built without compiling the code leaves every call that goes through a glob import of the iron prelude without a target. The Iron data extension rows and the sink that matches the canonical path of Response::with then do not apply, and githubsecuritylab/rust/iron-response-xss found nothing in code that starts with use iron::prelude::*. Recognize the API by its names for those calls, in files that use iron: a function or closure with a Request parameter is a source, the fields of the request and the method calls that have no target pass the data on, and a call of Response::with that has no target is a sink (a body on its own as well). A handler that the modelled source already reaches is reported once. Add a test file that has only the glob import, a test that lists its calls that have no target, a file with the same names from another framework that must not alert, and negative cases (constant body, length only, text/plain, encoded, sanitized, a parameter that is not a request). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752 * Rust: restrict the Iron fallback encoder match, report unregistered body-only handlers Two review findings on the fallback. A method whose name only contains escape or encode was taken to encode for HTML, which hid the taint of escape_default (it keeps markup) and of unescape_html. Only names that say HTML (escape_html, html_escape, encode_html) are taken to encode now. escape_default is an alert in the glob-only fixture, and a method that says escape_html is the safe form. A body that is passed on its own to a call of Response::with that resolves was reported only through the data extension sink, which needs a handler that Iron::new or Chain::new registers. A handler that nothing registers has no modelled source, so the flow was missed. Add the sink for the flows from the request parameter, and leave the flows of modelled sources to the standard query. Add the regression in main.rs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752
felickz
added a commit
that referenced
this pull request
Nov 26, 2026
… that pass a call that has no target (#267) * [Query Fix - githubsecuritylab/rust/iron-response-xss] - find Iron response XSS when the prelude calls have no target (#264) * Rust: find Iron response XSS when the prelude calls have no target A database that is built without compiling the code leaves every call that goes through a glob import of the iron prelude without a target. The Iron data extension rows and the sink that matches the canonical path of Response::with then do not apply, and githubsecuritylab/rust/iron-response-xss found nothing in code that starts with use iron::prelude::*. Recognize the API by its names for those calls, in files that use iron: a function or closure with a Request parameter is a source, the fields of the request and the method calls that have no target pass the data on, and a call of Response::with that has no target is a sink (a body on its own as well). A handler that the modelled source already reaches is reported once. Add a test file that has only the glob import, a test that lists its calls that have no target, a file with the same names from another framework that must not alert, and negative cases (constant body, length only, text/plain, encoded, sanitized, a parameter that is not a request). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752 * Rust: restrict the Iron fallback encoder match, report unregistered body-only handlers Two review findings on the fallback. A method whose name only contains escape or encode was taken to encode for HTML, which hid the taint of escape_default (it keeps markup) and of unescape_html. Only names that say HTML (escape_html, html_escape, encode_html) are taken to encode now. escape_default is an alert in the glob-only fixture, and a method that says escape_html is the safe form. A body that is passed on its own to a call of Response::with that resolves was reported only through the data extension sink, which needs a handler that Iron::new or Chain::new registers. A handler that nothing registers has no modelled source, so the flow was missed. Add the sink for the flows from the request parameter, and leave the flows of modelled sources to the standard query. Add the regression in main.rs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752 * Rust: report Iron XSS flows that pass a call that has no target Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Copilot-Session: 4124a708-0b20-41df-a2e2-c945fbf86752
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
b88b9f6313e9327836dc0b6fe8dbf182d5dc1098main.↑ Mutations of the file guard, the method step, the one path clause, the field guard, the HTML encoder match and the sink for a resolved body on its own each changed the result as intended.
↑ The previous commit of this branch passed all 31 CI checks. Copilot's two findings on it (an encoder match by substring that hid the taint of
escape_default, and a missed body on its own in a handler that nothing registers) are fixed here and pinned by fixtures.↑ On the database that a default setup run built (no build) from a public Iron sample, the unchanged query reports 0 alerts and this one 3, including the intended one. The sample that sanitizes the body reports none.
↑
measureon two local Rust databases (the larger has about 19,000 files): cost class low, own predicates 0.08 s and 0.50 s, 0 alerts.↓ The fallback goes by names and no local corpus uses Iron, so its precision on real programs is untested beyond that one sample.
↓ CI for this commit and a Copilot re-review are pending.
getStaticTarget()), the query and the data extension rows match resolved targets only, and the same query with the fallback finds the alert there.↓ Why the extraction leaves them unresolved is not determined. The fix does not depend on it.
Response::with.↓ Not confirmed in a live scan, which needs a release that carries this change and a new scan.
Summary
githubsecuritylab/rust/iron-response-xssfound nothing in code that uses Iron through a glob import of its prelude (use iron::prelude::*;), which is how Iron programs usually import it. This adds a fallback that recognizes the API by its names when the calls have no target, in files that useiron, with tests for it.Why
A database that is built without compiling the code (code scanning default setup uses
buildMode: none) leaves the calls that go through names from the prelude glob without a target:Iron::new,.http,Response::withand the methods of the request. The Iron data extension rows and the query's sink forResponse::withmatch canonical paths, so none of them applies. The tests did not show it, because the fixture of the query also imports the same names explicitly, and that makes them resolve.Reproduction (CLI 2.27.5,
iron = "0.6.1",--build-mode none, calls listed withgetStaticTarget().getCanonicalPath()):Iron::new,.http,Response::with,.path())use iron::prelude::*;at the crate root, or inside a module when nothing else imports the namesuse iron::prelude::{IronResult, Request, Response};use iron::{Iron, IronResult, Request, Response};The cause is not determined. The
ironcrate is edition 2015, which may be relevant.What is changed
rust/src/common/IronFallback.qll(new):isIronFile(ausewhose first segment isiron, orextern crate iron),IronRequestParameter,ironUnresolvedStepandisUnresolvedIronResponseWith.rust/src/security/CWE-079/IronResponseXss.qluses them. In files that useiron, for calls that have no target:Request,&Requestor&mut Requestis a source,url,headers,bodyandextensionsfields of a request that do not resolve to a field, and the result of a method call that has no target, carry the data on (except methods that only tell a property, such aslen, and names that say that they escape or encode for HTML, such asescape_html, which are taken to do so),Response::withthat has no target is a sink for the elements of a modifier tuple, and for a body that is passed on its own, as the data extension row does for a call that resolves.IronResponseXss.ql:Response::withthat resolves is a sink too, for the handlers that no registered source reaches (one that a router registers, for example). The standard query reports the registered ones, so this query leaves them to it,IronResponseXss.qhelpdescribes the fallback and its limits.glob_prelude.rs: a file that has only the glob import, with 8 alerts (a tuple, a body on its own, a tuple that is built first, a nested tuple, the query string, a value that goes through another method, a value that goes throughescape_default, which keeps markup, and a closure handler) and 6 safe forms (a constant body, the length only,text/plain, a method that says that it escapes for HTML, a sanitizer call, a parameter that is not a request),GlobCalls.ql: lists the calls of that file that have no target, so that the test changes if the extraction ever resolves them and the file stops exercising the fallback,other_framework.rs: the same names from another framework, with nouseofiron, which must not alert,main.rsthat nothing registers (a tuple, and a body on its own to a call that resolves), which now alert (and add two rows to the model test).Evidence
codeql test runpasses with the pinned CLI (4 tests, 19 alerts). Compared withmain, no row of the existing fixture's expected files is removed or changed: the 9 alerts and the model rows stay, and the two handlers that nothing registers add 2 alerts and 2 model rows. With the unchanged query the glob-only file has no alert.--warnings=errorand the format check passes.escape,encodeanywhere in a name) theescape_defaultalert goes (18 instead of 19), without the sink for a resolved body on its own the alert of the unregistered body-only handler goes (18), and without the clause that leaves registered handlers to the standard query the registered body-only handler is reported twice (20).reqwestrequest, a remote source of the standard query. The sample that sanitizes the body withammonia::cleanreports none (cleanresolves there, and no taint comes out of it).iron, although they hold 134,270 and 28,376 calls that have no target, and the file guard keeps the fallback away from all of them. So this shows that the change is cheap and quiet elsewhere, not how precise it is on Iron programs.measure, idle machine): the whole run takes 9 s and 21 s on the two databases, the query's own predicates 0.08 s and 0.50 s (the largest one 0.43 s), no cartesian product, cost class low.Known limitations
Requestof another crate in a file that usesironis a source, and every method of the request that has no target passes its receiver on, so a method that encodes the value is recognized only when its name says that it escapes or encodes for HTML (escape_html,html_escape), and one that does it under another name, or only partly (escape_defaultkeeps markup), is not.Notes
@precision mediumand the tags are unchanged. The query stays in the default Rust suite.