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

rustdoc search xss exploit #13884

Closed
misterhat opened this issue May 1, 2014 · 6 comments · Fixed by #13895
Closed

rustdoc search xss exploit #13884

misterhat opened this issue May 1, 2014 · 6 comments · Fixed by #13895
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@misterhat
Copy link

The input for doc searches isn't sanitized, allowing for arbitrary HTML input.

http://static.rust-lang.org/doc/master/std/index.html?search=%3Cxmp%3E

@huonw huonw added the A-rustdoc label May 1, 2014
@adrientetar
Copy link
Contributor

Is this problematic? Afaik everything is done client-side.

@tomjakubowski
Copy link
Contributor

Yes. For example, if rustdoc documentation is served on a site that uses a cookie for authentication, an attacker could perform XHRs on the victim's behalf by injecting a <script> tag. It's not particularly problematic on the static.rust-lang.org site, though.

@adrientetar
Copy link
Contributor

But the search is done with client-side javascript on a client-side resources index; how can you secure that?

@tomjakubowski
Copy link
Contributor

I'm not sure what you mean by the search being unsecurable because the index is searched on the client. The problem is that the Javascript responsible for rendering the search query does not properly escape it, so an attacker can insert arbitrary HTML and therefore execute arbitrary Javascript in another user's browser merely by tricking the user into following a link. This is easily fixed by escaping query.query and query.type here: https://github.com/mozilla/rust/blob/master/src/librustdoc/html/static/main.js#L393-L394

If you're not convinced of the danger, see this link (warning: displays an alert dialog) for an example. If I were more nefarious, and I knew of a site that served rustdoc HTML documentation on the same domain as another site that uses cookie authentication, I could impersonate a user of this site just by convincing them to follow a link I've sent them.

@adrientetar
Copy link
Contributor

I see thanks for the explanations, opened up a PR for it.

@steveklabnik
Copy link
Member

I knew of a site that served rustdoc HTML documentation on the same domain

I think this is the part that makes me go from "meh" to "OH!." There's not a lot of damage on rust-lang.org, but we shouldn't open up others to these issues.

bors added a commit that referenced this issue May 4, 2014
arcnmx pushed a commit to arcnmx/rust that referenced this issue Jan 9, 2023
…Veykril

fix: unescape inline module names in module resolution

Fixes rust-lang#13884
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants