Skip to content
Access control Write-up Intermediate

How I Used the js.map File to Gain Admin Access

An exposed JavaScript source map file allowed reconstruction of the application's source code, revealing GraphQL mutations including one to update user roles without proper access controls. The attacker created a new user and then used the exposed mutation to set that user's role to admin, gaining full administrative control.

medium.com

Published on medium.com

In the world of web development, source maps (.js.map files) are incredibly useful for debugging. They link compiled or minified JavaScript back to its original source code, making it easier for developers to pinpoint issues.

CypherNova1337, on medium.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

Root cause

Likely the server-side GraphQL mutation for updating user roles lacked proper authorization checks, and the source map file was publicly accessible, exposing the mutation's structure.

Impact

The attacker could gain full administrative control over the application, including performing admin actions and accessing sensitive data.

What the attacker needed

Publicly accessible .js.map file; GraphQL endpoint exposed; no authentication required for mutations

The fix

The source map files should not be publicly accessible in production, and the server-side GraphQL mutations should enforce proper authorization checks.

How it was found

  1. Discover an accessible main.js.map file.
  2. Use Sourcemapper to download and reconstruct the JavaScript source code.
  3. Review the extracted files to find GraphQL mutations, including createUser and updateUserRole.
  4. Use curl to send a createUser mutation to add a new user.
  5. Use curl to send an updateUserRole mutation to set the new user's role to admin.
  6. Access the adminPanel and perform adminActions.

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.

A source map is a file that helps developers debug by linking minified code back to the original readable code. If this file is left publicly accessible, anyone can download it and see the full source code, including hidden API endpoints and how they work. In this case, the exposed code showed a way to change a user's role to admin, which the attacker used to take over the application.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.