Skip to content

Fix XSS from cookie tossing #10431

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Fix XSS from cookie tossing #10431

wants to merge 3 commits into from

Conversation

JarLob
Copy link

@JarLob JarLob commented Apr 29, 2025

Every time NuGetGallery receives a HTTP request it looks for a cookie named __Controller::TempData and loads key-value pairs from its
content into WebViewPage.TempData dictionary. The value of the TempData["RawErrorMessage"] is is injected into HTML as is without any encoding in Header.cshtml - basically in all pages.

The cookie is untrusted input and can be set for example from related subdomain.
See https://www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-zheng.pdf and https://media.blackhat.com/eu-13/briefings/Lundeen/bh-eu-13-deputies-still-confused-lundeen-slides.pdf for more information.

For example, a XSS vulnerability in a subdomain of https://nuget.org (or any other deployment of NuGetGallery) would enable an attacker to create a __Controller::TempData "shadow" cookie in a victim's, NuGetGallery administrator, browser with a /Admin path. This cookie would supersede the genuine path=/; HttpOnly; Secure cookie when the victim opens their NuGetGallery deployment Admin area.

This is not exploitable by itself as it requires another XSS in subdomain or MitM to unencrypted subdomain endpoint. However it 1. allows for persistence (the cookie is reloaded and injected for every page visit) 2. Doesn't require the browser user to be logged into NugetGallery to inject XSS payload into the shadow cookie when visiting the vulnerable subdomain.

@JarLob JarLob requested a review from a team as a code owner April 29, 2025 17:00
@lyndaidaii lyndaidaii self-assigned this Apr 29, 2025
@lyndaidaii lyndaidaii added this to the Sprint 2025-05 milestone Apr 29, 2025
@lyndaidaii lyndaidaii changed the base branch from main to dev April 29, 2025 21:19
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

Successfully merging this pull request may close these issues.

6 participants