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

Illegal attributes that begin with = #2143

Open
paj28 opened this issue Jun 15, 2024 · 0 comments
Open

Illegal attributes that begin with = #2143

paj28 opened this issue Jun 15, 2024 · 0 comments

Comments

@paj28
Copy link

paj28 commented Jun 15, 2024

If we parse an attribute like <test =foo=bar/> Then in the DOM the attribute appears with the = sign, but when re-serialized it is generated without.

Code:

val doc = Jsoup.parse("<test =foo=\"bar\"/>")
for (elem in doc.select("test")) {
    for (attr in  elem.attributes()) {
        println(attr.key)
    }
}
println(doc.html())

Output:

=foo
<html>
 <head></head>
 <body>
  <test foo="bar" />
 </body>
</html>

This is problematic as if an application is doing validation on the key, to prevent XSS attacks, this can be a way to bypass the validation. I discovered this issue (in a lab environment, not a live app) just now.

The key for output can be accessed using getValidKey(). A potential solution to this is to normalise keys during parsing.

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

No branches or pull requests

1 participant