sts: build_sts_error_response writes caller-controlled text into XML unescaped

Open Beginner friendly
#160 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
api, security

Research direction

Start at multistore_sts::build_sts_error_response and trace the STS route mounted by Router::with_sts. Check how caller-controlled message values reach the XML body, then ensure the generated application/xml remains escaped and parseable for the listed error paths. Done means special characters in role ARNs, key IDs, and echoed header fields cannot create markup or malformed XML.

Written by the indexing model from the issue text.

Description

multistore_sts::build_sts_error_response interpolates the error message into the <Message> element unescaped:

let xml = format!("...<Code>{}</Code><Message>{}</Message>...", code, message);

Several messages carry caller-controlled text:

  • ProxyError::RoleNotFound(role_arn) → role not found: {role_arn}
  • find_key → key '{kid}' not found in JWKS, where kid comes from the unverified JWT header
  • verify_token errors that echo header fields such as alg

The body is served as application/xml. A host's CORS layer may add access-control-allow-origin: *.

Impact:

  • Script injection: a RoleArn such as <x:script xmlns:x="http://www.w3.org/1999/xhtml">alert(document.domain)</x:script> returns a document that browsers render as XHTML, running script on the proxy's origin.
  • Unparseable errors: any & in a RoleArn makes the error body malformed XML, so SDKs fail to parse it.

This is reachable through the STS route that Router::with_sts mounts. A host can escape errors it builds itself, but not this route's.

Suggested fix: escape &, < and > (and " if attributes are ever added) in message before formatting. The Code values are fixed strings.

Found in review of source-cooperative/data.source.coop#237. Its own exchange paths now build escaped bodies (source-cooperative/data.source.coop#246); the person route still goes through this builder.

Dominant language
Rust
Stars
21
Forks
1
Avg merge
16h 39m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/multistore

All issues in developmentseed/multistore

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.