-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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: parenthetical after attribute syntax breaks HTML #14814
Comments
HTML in markdown get interpreted literally i.e. /// <script>alert("hi");</script>
fn foo() {} is also an XSS risk: <div class='docblock'><script>alert("hi");</script>
</div></section> |
The first one I view as a fact of using markdown, and can be fixed with:
The second one I view as bit of not a bug because you're the one writing documentation, so it's not necessarily XSS because no one is injecting anything into your page? |
If we had a public service hosting documentation (well, anyone hosting such things, I guess Rust CI may be affected), then someone can write a Rust library that injects javascript into that site, meaning it should be hosted on something with no credentials. |
It would probably be reasonable to add an option to rustdoc which enables Hoedown's |
Doing this safely requires completely parsing the HTML and whitelisting tags / attributes at the AST level, then re-serializing as well-formed HTML. Anything short of that will have loopholes due to browsers' attempts to interpret seriously malformed HTML (see The Tangled Web chapter 4). |
I'm going to close this as not-a-bug as by using Markdown we're committing ourselves to one form of syntax or another, and any XSS vulnerabilities or vectors would probably be handled when we set up hosting! |
I'd recommend that we make a very clear warning somewhere that hosting docs for arbitrary crates opens up XSS attacks and proper precautions should be taken. It's important to remember that crates.io isn't the only domain hosting rustdocs. — On Mon, Apr 6, 2015 at 3:18 PM, Alex Crichton notifications@github.com
|
Er, I mean docs.rust-lang.org or whatever. Although it's conceivable that crates.io (or a sub domain) will host docs as well some day. — On Mon, Apr 6, 2015 at 3:18 PM, Alex Crichton notifications@github.com
|
Better register |
fwiw I think html5ever is up to this task now. |
@tomjakubowski good idea! I've opened #24160 |
@kmcallister According to rust-lang/crates.io#91, some members of the community have reserved rustdoc.org and doc.rs for this purpose. So getting a domain is not a blocker. |
produces
because it parses as a Markdown link. The right thing to do is put backtics around the attribute syntax, but this is still a really confusing failure.
It would also be an XSS vulnerability if we hosted docs generated from user contributed libraries:
But the conservative solution there is to put user content on another origin (e.g.
rust-user-content.org
) which doesn't hold any credentials.The text was updated successfully, but these errors were encountered: