Skip to content

[Query Fix - githubsecuritylab/rust/iron-response-xss] - report flows that pass a call that has no target - #267

Merged
felickz merged 2 commits into
mainfrom
copilot/rustiron-response-xss-unresolved-prelude
Nov 26, 2026
Merged

felickz merged 2 commits into
mainfrom
copilot/rustiron-response-xss-unresolved-prelude

Conversation

@felickz

@felickz felickz commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

IronResponseXss.ql dropped every flow from a modelled source (Xss::Source) into a Response::with body that resolves, assuming that the standard rust/xss query reports it. If a method call that has no target lies between the request and the body, only this query's ironUnresolvedStep follows it. Both queries then miss the flow:

let res = req.url.path();
let loud = res.shout();   // no target: the standard analysis stops here
Ok(Response::with(loud))  // previously reported by neither query

Changes

  • StandardXssConfig / StandardXssFlow: a copy of the standard query's configuration: Xss::Source, Xss::Sink, Xss::Barrier, and no additional steps. It finds exactly the flows that the standard query reports.
  • where clause: a resolved-body result is now dropped only when StandardXssFlow reaches the body from the same source. The other suppression, for unmodelled request parameters, is unchanged.
    not (
      sinkNode.getNode() instanceof IronResolvedResponseBody and
      exists(DataFlow::Node standardSink |
        StandardXssFlow::flow(sourceNode.getNode(), standardSink) and
        standardSink.getLocation() = sinkNode.getNode().getLocation()
      )
    )
    The match is by location because the data extension row's sink is a separate node that the library creates, printed at the argument's location, and is never the argument's expression node. I used this variant rather than matching on the argument node itself, because that variant can miss macro arguments such as format!(...).
  • Docs: the doc comment of IronResolvedResponseBody and the "Known limitations" section of the .qhelp now describe the two cases this query reports: an unregistered handler, and a call that has no target in the path.
  • Test: bad_registered_unresolved_step_handler is appended to main.rs, with Response::with(loud) on line 173.

Evidence (local run)

CI does not run on a pull request whose base is not main, so these results come from a local codeql test run on rust/test/security/CWE-079/IronResponseXss.

  • Before the query change: with the fixture added, the test failed only on the missing alert at main.rs:173. XSS.qlref still passed, which confirms that the standard query misses the flow.
  • After the query change: the alert count goes from 19 to 20. The .expected diffs contain only added rows:
    • IronResponseXss.expected: the new flow's edges and nodes, and its #select row.
    • IronModels.expected: the new source and sink.
    • No other changes: XSS.expected and GlobCalls.expected are unchanged.

Cost

The second instance of the standard taint analysis adds some evaluation cost to this query.

@felickz
felickz added this pull request to stack #268 November 25, 2026 19:21
Copilot AI linked an issue Nov 25, 2026 that may be closed by this pull request
Copilot AI balanced review requested due to automatic review settings November 25, 2026 19:38
@felickz felickz changed the title [WIP] Fix XSS report flows in IronResponseXss.ql [Query Fix - githubsecuritylab/rust/iron-response-xss] - report flows that pass a call that has no target Nov 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the change addressing missed Iron XSS flows.

No open issues 🎉

What changed in this PR

Fixes a missed Iron XSS flow when an unresolved method call interrupts standard taint tracking. The community query now suppresses resolved response-body results only when the standard analysis finds a flow from the same source, addressing #265.

Changes:

  • Adds a standard XSS analysis configuration and matches its sinks by location to avoid duplicate reports.
  • Adds a registered-handler regression fixture and expected results for the previously missed flow.
  • Updates query documentation to explain when the fallback query reports resolved response bodies.
File Description
rust/​test/​security/​CWE-079/​IronResponseXss/​main.rs Adds a regression fixture with an unresolved method call.
rust/​test/​security/​CWE-079/​IronResponseXss/​IronResponseXss.expected Adds the newly detected flow and alert.
rust/​test/​security/​CWE-079/​IronResponseXss/​IronModels.expected Records the fixture’s modelled source and sink.
rust/​src/​security/​CWE-079/​IronResponseXss.ql Checks standard flow reachability before suppressing results.
rust/​src/​security/​CWE-079/​IronResponseXss.qhelp Documents the revised reporting behavior.

Review effort: Balanced

@felickz
felickz marked this pull request as ready for review November 26, 2026 06:18
Base automatically changed from rust/iron-response-xss-unresolved-prelude to main November 26, 2026 06:19
felickz and others added 2 commits November 26, 2026 01:19
…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
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@felickz
felickz force-pushed the copilot/rustiron-response-xss-unresolved-prelude branch from 9afb04a to 4cec067 Compare November 26, 2026 06:19
@felickz
felickz merged commit 7e4deb8 into main Nov 26, 2026
29 checks passed
@felickz
felickz deleted the copilot/rustiron-response-xss-unresolved-prelude branch November 26, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust Iron XSS: report flows that pass a call that has no target

3 participants