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

Broken XSS example #239

Open
nharraud opened this issue Jul 29, 2021 · 0 comments
Open

Broken XSS example #239

nharraud opened this issue Jul 29, 2021 · 0 comments

Comments

@nharraud
Copy link

Hi,

I noticed that commit 7c293e7 has broken the XSS example.

1/ The website property is not saved in the database. Thus it will never be displayed.

profile.updateUser(
parseInt(userId),
firstName,
lastName,
ssn,
dob,
address,
bankAcc,
bankRouting,
(err, user) => {

2/ The website property is not returned after an update
return res.render("profile", {
updateError: "Bank Routing number does not comply with requirements for format specified",
firstNameSafeString,
lastName,
ssn,
dob,
address,
bankAcc,
bankRouting,
environmentalScripts
});

3/ The profile.html page still uses firstNameSafeString as an url, which is confusing.
<a href="{{firstNameSafeString}}">Google search this profile by name</a>

4/ The profile.js:displayProfile does not return firstNameSafeString anymore
doc.website = ESAPI.encoder().encodeForHTML(doc.website)
// fix it by replacing the above with another template variable that is used for
// the context of a URL in a link header
// doc.website = ESAPI.encoder().encodeForURL(doc.website)
return res.render("profile", {
...doc,
environmentalScripts
});

5/ Also shouldn't firstNameSafeString and website be encoded with encodeForHTMLAttribute instead of encodeForHTML and encodeForURL? The current code seems to contradict the tutorial.
// doc.website = ESAPI.encoder().encodeForURL(doc.website)

6/ the firstname is not sanitized after an update.
const firstNameSafeString = firstName

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