Unprotected Admin Functionality with Unpredictable URL: The Secret Path Was in the JavaScript (PortSwigger Lab Walkthrough)

A step-by-step PortSwigger lab walkthrough: the admin panel had a random, unguessable URL, but the page's own JavaScript shipped that path to every visitor. Read the page source, open the panel directly, and learn why an unpredictable URL is not access control.

Difficulty: Apprentice
Category: Access control
Lab: Unprotected admin functionality with unpredictable URL

Nobody could guess the admin URL. They didn't have to. The page's own JavaScript sent it to every visitor.

This is the follow-up to the previous lab, where the admin path leaked in robots.txt. Same access control category, but this time the admin panel's URL is not predictable. Again, no Burp Suite needed.

The goal

The lab description: the admin panel is located at an unpredictable location, but the location is disclosed somewhere in the application. Delete the user carlos

The admin panel sits at an unpredictable location, but that location is disclosed somewhere in the application. Find it, and delete the user carlos.

Where to look

As in the previous lab, endpoints can be exposed in HTML comments, JavaScript files, and other common files a website needs for its features or configuration. This time, the endpoint is disclosed in JavaScript code.

Step 1: View the page source

Open the lab. On the shop page, right-click and choose View page source. Scroll down until you reach the JavaScript.

The page source: var isAdmin = false; if (isAdmin) { ... adminPanelTag.setAttribute('href', '/admin-ztbggn') ... }

js
var isAdmin = false;
if (isAdmin) {
   var topLinksTag = document.getElementsByClassName("top-links")[0];
   var adminPanelTag = document.createElement('a');
   adminPanelTag.setAttribute('href', '/admin-ztbggn');
   adminPanelTag.innerText = 'Admin panel';
   topLinksTag.append(adminPanelTag);
   ...
}

There it is. The script only adds an "Admin panel" link to the page if isAdmin is true, so normal users never see the link. But the code itself, including the path /admin-ztbggn, is sent to every visitor's browser. (The random part of the path is different in every lab instance.)

Step 2: Open the admin panel directly

Copy the path, paste it after the lab URL in the address bar, and press Enter.

The admin panel opens with no password: Users wiener and carlos with Delete links

It opens without a password or anything else.

Step 3: Delete carlos

Click Delete next to carlos, and the lab is solved.

Congratulations, you solved the lab. User deleted successfully

What was going on?

Similar to the previous lab, the shop's admin panel was exposed in the website's own files. The URL was unpredictable, but it was still exposed.

To put that in numbers: a 6-letter lowercase suffix like ztbggn has 26^6 = 308,915,776 possible values. That's hard to guess. But reading the page source takes one request. An unguessable URL only helps if it stays secret, and here the site gave it away.

Developers sometimes forget to remove sensitive links, or even credentials, from code and comments, and this kind of issue is common in real applications too.

The fix

  • Enforce access control on the server: every request to the admin panel must come from a logged-in admin. Hiding the link and hoping nobody finds it is not protection.
  • Keep sensitive endpoints out of client-side files. Anything in HTML, JavaScript, robots.txt or sitemap.xml is public.

Watch the video walkthrough

https://www.youtube.com/@devsecknight

References

ResourceWhy it is useful
PortSwigger Lab: Unprotected admin functionality with unpredictable URLThe official lab used in this walkthrough.
PortSwigger: Access control vulnerabilitiesPortSwigger's guide to broken access control and how to prevent it.
OWASP Top 10: Broken Access ControlWhy broken access control is the number one web application risk.

This is a PortSwigger practice lab, built to be hacked. Only test systems you own or have written permission to test. Security audits and private pentests: click to reveal email

Related posts