Skip to content
XSS Write-up Intermediate

Google code in XSS

User-supplied text was embedded in a JSON script block without escaping the closing script tag, allowing an attacker to break out and inject a script. Combined with AngularJS expression evaluation, this bypassed CSP and executed arbitrary JavaScript for anyone viewing the comments.

Thomas Orlita Follow

Published on websecblog.com

Google Code-in is an online programming competition for students hosted by Google that takes place every year.

Thomas Orlita, on websecblog.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could execute arbitrary JavaScript in the context of any user viewing the comments page, including mentors and site admins, potentially leading to account compromise or other actions.

What the attacker needed

Ability to post a comment; victim views the comments page

The fix

The vulnerability was fixed by the development team the day after the report.

How it was found

  1. Submit a comment containing a payload that closes the script tag and includes an AngularJS expression.
  2. The comment is stored and included in the JSON data inside a script tag.
  3. When the comments page is loaded, the script tag is terminated early and the AngularJS expression is evaluated, executing JavaScript.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The website put user comments inside a script tag that holds data. The site escaped quotes but not the sequence that ends a script tag, so a comment could close the script tag early and add new HTML. Because the site used AngularJS, which evaluates expressions in the page, the attacker could run JavaScript despite a security policy that normally blocks scripts.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Thomas Orlita

View all

7 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.