How I Bypassed a Trusted URL Allowlist to Inject CSS and Trigger External Browser Requests
The application validated that a user-supplied image URL started with a trusted CDN prefix but then inserted the entire string into a CSS background declaration. An attacker could craft a URL that passes the prefix check but contains CSS syntax to break out of the url() function and add a second background-image layer pointing to an external server, causing the victim's browser to make a request to that server.
Published on medium.com
Bug Bounty
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.
Context
The target was a social-sharing landing page in a production web application. The page displayed information associated with a user profile, including a profile image, and it accepted the image URL through a query parameter:
GET /social/index.html?user_photo_url=<IMAGE_URL>
The intended flow was simple: extract the image URL from the query string, check that it begins with an approved CDN prefix, insert the image into a profile placeholder, and render the page. A secondary input source existed as well, a Base64-encoded deep-link parameter, and both sources eventually reached the same CSS rendering logic. The application also used the same JavaScript bundle and the same profile-image placeholder on another page, which matters later.
Setup
The attack required no authentication. A victim only needed to open a crafted link. The proof of concept was validated in a live headless Chromium browser, and the researcher used a test endpoint under their own control rather than attempting to collect sensitive information. Domain and infrastructure identifiers in the published code were replaced with generic examples such as cdn.example.com and attacker.example.
Finding it
While examining the client-side JavaScript, the researcher identified this pattern:
const currentUrl = new URL(window.location.href);
const deepLink = currentUrl.searchParams.get( "deep_link_sub1");const photoUrl = currentUrl.searchParams.get("user_photo_url") || decodeDeepLink(deepLink).user_photo_url;const trustedBaseUrl = "https://cdn.example.com/media/profile-photos";if ( photoUrl && photoUrl.startsWith(trustedBaseUrl)) { $(".profile-img-placeholder").css( "background", 'url("' + photoUrl + '")' );}
Two operations stood out. The first was the prefix check:
photoUrl.startsWith(trustedBaseUrl)
The second was the string concatenation into CSS:
'url("' + photoUrl + '")'
The application was using a string-prefix check as a security boundary and then placing the same string into a CSS expression. The developer's apparent assumption was that if the image URL begins with the trusted CDN address, it must be safe. But startsWith() does not validate a complete URL; it only checks whether one string begins with another. The value passes the check while still containing characters that have special meaning inside CSS, and those characters become dangerous when the application concatenates the value into a background declaration. This is a validation rule that does not match the context in which the input is used.
Exploitation
Step 1: Understand the intended CSS
Normally the application generates a single background image:
background: url("https://cdn.example.com/media/profile-photos/avatar.png");
Step 2: Craft a value that passes the prefix check
The attacker-controlled value begins with the approved CDN prefix, so validation succeeds:
https://cdn.example.com/media/profile-photos"),url("https://attacker.example/beacon.png
When inserted into the concatenation 'url("' + photoUrl + '")', the resulting declaration becomes:
background: url("https://cdn.example.com/media/profile-photos"), url("https://attacker.example/beacon.png");
The browser interprets this as two separate background-image layers: the first points to the expected CDN, the second to the attacker-controlled server. The important characters are "),url(". The " closes the original CSS string, the ) closes the original url() function, the , introduces another background-image layer, and url(" begins a new resource reference. The application's own closing characters complete the second url() function, so the resulting CSS is valid and the attacker has escaped the intended single-image context.
Step 3: Deliver the payload through the query parameter
The crafted request used the vulnerable query parameter:
GET /social/index.html?user_photo_url=<URL_ENCODED_PAYLOAD>
Once the page loaded, its own JavaScript processed the query parameter and inserted the attacker-controlled value into the background property. The injection was not stored on the server; it was triggered entirely by the URL supplied to the victim.
Step 4: Confirm the injection in Chromium
Identifying suspicious JavaScript is not the same as proving a vulnerability, so the researcher tested the crafted link in a live headless Chromium browser and inspected the target element's inline style. The result was equivalent to:
background: url("https://cdn.example.com/media/profile-photos"), url("https://attacker.example/beacon.png");
This confirmed that the attacker-controlled input had altered the CSS declaration. The browser's network activity then showed an outbound request to the external resource, which demonstrated that the injection produced a real browser-side effect. The complete chain was: the attacker-controlled URL parameter is read by client-side JavaScript, the prefix validation succeeds, the input is concatenated into CSS, the CSS parser creates two background layers, and the browser requests the attacker-controlled resource.
Step 5: Run negative controls
The researcher supplied an arbitrary external URL that did not begin with the approved CDN prefix. The application rejected it and no malicious background declaration was inserted. Supplying the injection payload beginning with the trusted prefix made validation pass and the browser loaded the second background-image resource.
| Test case | Result |
|---|---|
| Legitimate CDN image URL | Accepted |
| External URL without trusted prefix | Rejected |
| Trusted prefix followed by CSS syntax | Accepted |
| Second CSS background layer | Confirmed |
| External HTTP request | Confirmed |
This established that the vulnerability was not caused by a complete absence of validation. The guard was working exactly as programmed; the security model behind it was flawed.
Step 6: Trace the Base64 deep-link vector
Further analysis showed that the vulnerable value could also originate from the deep_link_sub1 parameter. The application decoded it with logic equivalent to:
function decodeDeepLink(value) { return JSON.parse(atob(value));}
The decoded object could contain a user_photo_url field, for example:
{ "user_photo_url": "https://cdn.example.com/media/profile-photos/avatar.png"}
That value then flowed into the same variable used by the direct query parameter. Both sources reached the same CSS sink, which illustrates that one vulnerable sink may be reachable through multiple attacker-controlled inputs. The direct query-parameter path was confirmed in the browser; the encoded path was established from the client-side code flow rather than a separately documented browser proof. Base64 encoding did not make the underlying input trustworthy, it only changed how the input was transported.
Root cause
The mistake was using a string-prefix check as a security boundary and then concatenating the same unparsed string into a CSS declaration. startsWith() guarantees only that the value begins with the trusted prefix; it says nothing about the rest of the string, and the CSS parser later interprets characters such as ", ), , and url( with their own meaning. Validation and final interpretation were not aligned. The existing defence, the prefix check, did not stop the attack because it was never designed to enforce the property the developer intended: that the complete value is a safe URL. The original report identified both routes as affected, because they shared the JavaScript bundle and the profile-image placeholder, though the strongest runtime evidence came from the social-sharing page.
Impact
The confirmed vulnerability had two primary effects. First, an attacker could construct a link that caused the victim's browser to request an external resource. When that request reached the attacker-controlled server, the server could observe ordinary request metadata, which depending on browser and network behaviour may include the public IP address, the User-Agent header, the request timestamp and other permitted request headers. This could be used as a tracking or telemetry beacon, but the external request did not automatically expose sensitive application data. Second, the attacker could alter the CSS background of the profile-image placeholder, gaining influence over part of the page's visual presentation. That could potentially support social engineering by displaying attacker-chosen visual content within an otherwise legitimate page, but the demonstrated control was limited to the affected CSS background property.
The vulnerability was reflected rather than stored, limited to a CSS background property, triggered by opening a crafted URL, capable of loading an external resource, and capable of modifying the rendered profile-image background. The investigation did not demonstrate JavaScript execution, session hijacking, sensitive-data exfiltration, account takeover, authenticated state changes or server-side code execution. No session cookies or authentication tokens were stolen and no authenticated actions were performed. This was not cross-site scripting: the browser did not execute an attacker-controlled script.
Fix
The safest fix is to stop treating an arbitrary string as a trusted image URL. The researcher proposed validating the complete URL by parsing it and checking its components:
function isAllowedProfileImage(input) { try { const url = new URL(input);
return ( url.protocol === "https:" && url.origin === "https://cdn.example.com" && url.pathname.startsWith( "/media/profile-photos/" ) && url.username === "" && url.password === "" ); } catch { return false; }}
This checks the actual parsed origin rather than trusting the beginning of an unparsed string, and the exact path constraints should be tailored to the application's legitimate image format. The vulnerable concatenation:
$(".profile-img-placeholder").css( "background", 'url("' + photoUrl + '")');
should be replaced by a dedicated image element after validating the URL:
const image = document.createElement("img");
if (isAllowedProfileImage(photoUrl)) { image.src = new URL(photoUrl).href;}
This avoids interpreting attacker-supplied characters as part of a CSS declaration. A restrictive Content Security Policy provides another layer, for example:
Content-Security-Policy: img-src 'self' https:
The actual policy must include all legitimate image sources required by the application. Finally, the same validation rules should be applied to values decoded from Base64 JSON: encoding is not sanitisation, and a value should not become trusted simply because it arrived through an encoded parameter.
Variants to test
- Other prefix checks feeding CSS sinks. Look for any
startsWith()or regex-anchored check on a URL that is later concatenated into aurl()value. A positive result is a value that passes the check and produces a second background layer or an outbound request in the browser. - Other CSS properties built by concatenation. Grep for
.css()calls that assemble strings from parameters. A positive result is a declaration whose parsed form differs from the intended single value. - Encoded or indirect sources. Test deep-link parameters, Base64 JSON, URL fragments, browser storage and cross-window messages that reach the same sink. A positive result is the same injection through a path that bypasses validation applied only to the direct parameter.
- Shared bundles across routes. Identify other pages loading the same JavaScript bundle and the same placeholder element. A positive result is the same source-to-sink pattern on a second route, ideally confirmed with a separate browser test.
- Negative controls. Always submit an unrelated external URL that should be rejected. A positive result is rejection of the control and acceptance of the trusted-prefix payload, which isolates the exact weakness.
Lessons learned
Security checks can create a false sense of safety: the application contained validation logic, but the logic did not enforce the property the developer intended. Prefix validation is not complete URL validation, and the final parser determines the risk, because input that appears to be a URL may become dangerous when inserted into CSS syntax. Encoded input is still untrusted input. Browser-based evidence matters: the decisive proof was not merely the injected string but the browser's interpretation of it and the resulting network request. Negative controls make findings stronger, and accurate impact assessment is essential. Don't just look for missing validation; look for validation that checks the wrong thing.
What happened, in plain words
A website had a page that showed a user's profile, including a small profile picture. The address of that picture was taken from the web address (the URL) the visitor arrived with. Before using the address, the site checked one thing: does it start with the address of the company's own image server (a CDN)? If yes, the site put the address into a piece of styling code called CSS, which tells the browser what to draw in the background of the picture area.
The check looked sensible but was too weak. It only looked at the beginning of the address and ignored everything after it. By putting the trusted beginning first and then some extra characters, an attacker could break out of the place where the address was supposed to sit and add a second background image pointing at a server the attacker controls. When a victim opened the crafted link, their browser quietly made a request to that attacker server.
This is called CSS injection. It is not the same as running JavaScript in the victim's browser (cross-site scripting), and it did not steal cookies or log anyone in as someone else. The confirmed effects were: the victim's browser contacted an outside server, and the attacker could change what the profile picture area looked like. The researcher proved it in a real Chromium browser and used negative controls to show the behaviour depended on the trusted prefix.
Below, every step is explained from zero, in the same order as the technical write-up, with the same requests and payloads.
Some background you need first
Before the steps make sense, here are the ideas the whole report depends on. Each one is explained as if you have never met it.
What a URL is
A URL is the address you type in the address bar, like https://example.com/photos/cat.png. It has parts:
https:is the scheme (the protocol, the language the browser and server speak).example.comis the host or domain (which computer to talk to)./photos/cat.pngis the path (which file on that computer).- Anything after a
?is the query string, a list of named values, like?colour=blue&size=large.
A query parameter is one of those named values. In this report the important one is called user_photo_url, and it is supposed to carry the address of the profile picture.
What a CDN is
A CDN (content delivery network) is a service that stores and serves files, usually images, from servers spread around the world so pages load fast. Companies put their images on a CDN and trust that address. In this report the trusted CDN address is written as https://cdn.example.com/media/profile-photos. The real name was replaced with example.com so the report can be published safely.
What JavaScript is
JavaScript is the programming language that runs inside your browser. It is what makes a page react when you click, type or load a link. When a page loads, its JavaScript can read the URL, change what is on screen, and ask the browser to fetch things. The vulnerable code in this report is JavaScript that runs in the victim's browser, not on the server.
What CSS is
CSS (Cascading Style Sheets) is the language that describes how a page looks: colours, sizes, positions, backgrounds. A typical CSS rule for a background image looks like this:
background: url("https://cdn.example.com/media/profile-photos/avatar.png");
Read it as: "for the background, use the picture found at this address". The url(...) part is a function that says "fetch this resource". The quotes around the address are optional in CSS but common.
CSS has its own grammar, with characters that mean specific things: " starts or ends a quoted string, ) closes a function, , separates items in a list. If an attacker can slip those characters into a place where the site builds CSS, the browser will obey them as CSS, not as part of an address. That is the heart of this bug.
What a query parameter and a deep link are
A query parameter is a value in the URL after the ?, as described above. A deep link is a link that jumps straight to a specific place or state inside an app, often carrying data with it. Here the app also accepted a parameter called deep_link_sub1, which carried a bundle of data encoded in Base64 (explained below).
What Base64 is
Base64 is a way of writing any data using only letters, digits and a couple of symbols, so it can travel safely inside a URL or a text field. It is not encryption and it is not a security measure. Anyone can decode it. For example, the text hello becomes aGVsbG8= in Base64. The report uses Base64 to hide a small JSON object inside a URL parameter.
What JSON is
JSON is a simple text format for structured data, used everywhere on the web. It looks like this:
Curly braces hold an object, names in quotes are keys, and values follow a colon. The report uses JSON to carry a user_photo_url field inside the deep-link parameter.
What a cookie and a token are
A cookie is a small piece of data a website asks your browser to store and send back with every request to that site. It is how a site remembers you are logged in. A token is similar: a secret string that proves who you are, often stored in a cookie or in the browser's storage. Stealing a cookie or token can let an attacker act as you. This report is careful to say that no cookies or tokens were stolen.
What an HTTP request is
When your browser wants something from a server, it sends an HTTP request: a short message with a method (like GET, meaning "give me this"), a path, and headers (extra information such as which browser you use). The server replies with a response. When a page loads an image, the browser sends a GET request for that image. The whole point of this bug is to make the victim's browser send such a request to a server the attacker controls.
What a header is
A header is a labelled line in an HTTP request or response. For example, User-Agent tells the server which browser and operating system you use. Content-Security-Policy is a header a site can send to tell the browser which sources of images, scripts and styles are allowed. The report uses the latter as a defence.
What the vulnerability class is: CSS injection
CSS injection means an attacker can get their own text interpreted as CSS by the victim's browser. It is not the same as injecting JavaScript (that would be XSS, cross-site scripting). CSS injection can change how a page looks and can make the browser fetch external resources, which is what happened here. It cannot, by itself, run code or read your cookies.
What an allowlist is
An allowlist is a list of things that are permitted, and everything else is refused. Here the allowlist is a single trusted prefix: the CDN address. The site's check is "does the value start with this prefix?". The site's check is "does the value start with this prefix?", and the bug is that the check was too loose.
What a headless browser is
A headless browser is a real browser (here, Chromium, the engine behind Chrome) running without a visible window, controlled by a script. Researchers use it to load a page, inspect what the browser did, and capture network traffic, all automatically. It is real browser behaviour, not a simulation.
Context: the page and the feature
The target was a social-sharing landing page in a production web application. "Production" means the real, live site that real users use, not a test copy. The page displayed information about a user profile, including a profile image. The image address could be supplied through a query parameter:
GET /social/index.html?user_photo_url=<IMAGE_URL>
Line by line:
GETis the HTTP method: the browser is asking the server to send something back./social/index.htmlis the path of the page being requested.?starts the query string.user_photo_url=is the name of the parameter, followed by its value.<IMAGE_URL>is a placeholder for whatever address is supplied. In a real request it would be a URL, often percent-encoded (explained later).
The intended flow was simple, and the report lists it as four steps:
- Extract the image URL from the query string.
- Check that it begins with an approved CDN prefix.
- Insert the image into a profile placeholder.
- Render the page.
A placeholder here is an empty element on the page reserved for the profile image. The page fills it in with the image from the URL.
There was a second input source too: a Base64-encoded deep-link parameter. Both sources eventually reached the same CSS rendering logic. That matters because it means there was more than one way to deliver the same malicious value, which the report explores later.
The application also used the same JavaScript bundle and the same profile-image placeholder on another page. A JavaScript bundle is one big file containing all the JavaScript a site needs, shared across pages. If two pages load the same bundle, a bug in that bundle can affect both. The report comes back to this in the section on the second page.
Setup: how the test was run
The attack required no authentication. Authentication is proving who you are, usually by logging in. "No authentication required" means the attacker did not need an account, a password or any permission. A victim only needed to open a crafted link. That is what makes this kind of bug dangerous: the attacker sends a link, the victim clicks, and the victim's own browser does the rest.
The proof of concept was validated in a live headless Chromium browser. The researcher used a test endpoint under their own control rather than attempting to collect sensitive information. A test endpoint is a server the researcher owns, set up only to record that a request arrived. Using your own server is the ethical way to prove an outbound request without touching anyone else's data.
Domain and infrastructure identifiers in the published code were replaced with generic examples such as cdn.example.com and attacker.example. example.com and example are reserved names meant for documentation, so publishing them cannot point anyone at the real site.
Finding it: the vulnerable JavaScript
While examining the client-side JavaScript, the researcher found this pattern:
const currentUrl = new URL(window.location.href);
Line by line:
window.location.hrefis the full address of the page currently open in the browser, as a string.new URL(...)turns that string into a URL object, which lets the code read its parts (host, path, query parameters) easily.const currentUrl = ...stores the result in a variable calledcurrentUrlso it can be used below.
const deepLink = currentUrl.searchParams.get( "deep_link_sub1");const photoUrl = currentUrl.searchParams.get("user_photo_url") || decodeDeepLink(deepLink).user_photo_url;const trustedBaseUrl = "https://cdn.example.com/media/profile-photos";if ( photoUrl && photoUrl.startsWith(trustedBaseUrl)) { $(".profile-img-placeholder").css( "background", 'url("' + photoUrl + '")' );}
This block is dense, so here it is broken into its parts:
currentUrl.searchParams.get("deep_link_sub1")reads the value of thedeep_link_sub1query parameter. The result is stored indeepLink.currentUrl.searchParams.get("user_photo_url")reads the value of theuser_photo_urlquery parameter.||means "or": if the first value is missing or empty, use the second one.decodeDeepLink(deepLink).user_photo_urldecodes the deep-link value and takes itsuser_photo_urlfield. So the image address can come from either the direct parameter or the encoded one.const trustedBaseUrl = "https://cdn.example.com/media/profile-photos";is the trusted CDN prefix. This is the allowlist.if (photoUrl && photoUrl.startsWith(trustedBaseUrl))is the security check.photoUrl &&means "only continue ifphotoUrlis not empty".photoUrl.startsWith(trustedBaseUrl)asks: does the value begin with the trusted prefix? If yes, the code inside the braces runs.$(".profile-img-placeholder")selects the page element with the classprofile-img-placeholder, which is the profile image area. The$is a common shorthand from the jQuery library for finding elements..css("background", ...)sets the CSSbackgroundproperty of that element.'url("' + photoUrl + '")'builds the CSS text by gluing three pieces together: the literalurl(", then the value ofphotoUrl, then the literal"). This is string concatenation: joining text end to end.
Two operations stood out to the researcher. The first was the prefix check:
photoUrl.startsWith(trustedBaseUrl)
startsWith is a JavaScript method that answers one question: does this string begin with that other string? It returns true or false. It does not check the rest of the string, it does not parse the URL, and it does not look for special characters.
The second was the string concatenation into CSS:
'url("' + photoUrl + '")'
This takes whatever text is in photoUrl and drops it straight into CSS, between url(" and "). Whatever characters are in photoUrl become part of the CSS.
The application was using a string-prefix check as a security boundary and then placing the same string into a CSS expression. A security boundary is a line the attacker is not supposed to cross: here, "only images from our CDN may be used". The developer's apparent assumption was that if the image URL begins with the trusted CDN address, it must be safe. But startsWith() does not validate a complete URL; it only checks whether one string begins with another. The value passes the check while still containing characters that have special meaning inside CSS, and those characters become dangerous when the application concatenates the value into a background declaration. This is a validation rule that does not match the context in which the input is used.
An everyday comparison: imagine a bouncer at a club who only checks that your name badge starts with the word "VIP". You write "VIP, and also my friend here" on the badge, and the bouncer waves both of you in. The check was real, but it did not check what the bouncer thought it checked.
Exploitation
Step 1: Understand the intended CSS
Normally the application generates a single background image:
background: url("https://cdn.example.com/media/profile-photos/avatar.png");
Line by line:
background:is the CSS property being set.url("...")tells the browser to fetch the resource at that address and use it as the background.- The address inside the quotes is the CDN image. The browser will send one HTTP request for it.
This is the normal, intended behaviour: one image, one request, one trusted server.
Step 2: Craft a value that passes the prefix check
The attacker-controlled value begins with the approved CDN prefix, so validation succeeds:
https://cdn.example.com/media/profile-photos"),url("https://attacker.example/beacon.png
Line by line:
https://cdn.example.com/media/profile-photosis the trusted prefix. This is what makesstartsWithreturntrue."closes the CSS string that the application opened withurl(".)closes theurl(function that the application opened.,starts a new item in the CSS list, which forbackgroundmeans a second background layer.url("opens a newurl(function and a new string.https://attacker.example/beacon.pngis the attacker's server and file. The browser will request it.- The value ends without a closing
"or), because the application's own trailing")will supply them.
When inserted into the concatenation 'url("' + photoUrl + '")', the resulting declaration becomes:
background: url("https://cdn.example.com/media/profile-photos"), url("https://attacker.example/beacon.png");
Line by line:
background:is still the property.url("https://cdn.example.com/media/profile-photos")is the first background layer, pointing at the trusted CDN. This is the part the site intended.,separates the first layer from the second.url("https://attacker.example/beacon.png")is the second background layer, pointing at the attacker's server. This is the part the attacker added.;ends the declaration.
The browser interprets this as two separate background-image layers: the first points to the expected CDN, the second to the attacker-controlled server. The important characters are "),url(". The " closes the original CSS string, the ) closes the original url() function, the , introduces another background-image layer, and url(" begins a new resource reference. The application's own closing characters complete the second url() function, so the resulting CSS is valid and the attacker has escaped the intended single-image context.
An everyday comparison: the site hands you a form that says "write your address between these brackets: [ ... ]". You write my street] and also [attacker's street, and the form ends up listing two addresses. The brackets were supposed to contain one value; you added your own closing bracket and opened a new one.
Step 3: Deliver the payload through the query parameter
The crafted request used the vulnerable query parameter:
GET /social/index.html?user_photo_url=<URL_ENCODED_PAYLOAD>
Line by line:
GETasks the server for the page./social/index.htmlis the page path.user_photo_url=is the parameter the page reads.<URL_ENCODED_PAYLOAD>is a placeholder for the payload after URL encoding. URL encoding replaces characters that are not allowed in a URL with a percent sign and two hex digits. For example, a space becomes%20, a quote becomes%22, and)becomes%29. The browser or the attacker's link does this encoding so the payload travels safely in the address. The server or the page's JavaScript decodes it back to the original characters before using it.
Once the page loaded, its own JavaScript processed the query parameter and inserted the attacker-controlled value into the background property. The injection was not stored on the server; it was triggered entirely by the URL supplied to the victim. This is called a reflected vulnerability: the malicious value bounces off the page back to the victim's browser, and it is not saved anywhere. The opposite, stored, would mean the value is saved on the server and served to every visitor. Reflected means each victim must click the crafted link.
Why this step matters: it shows the attack needs no account and no server-side change. The attacker only needs to get the victim to open a link.
Step 4: Confirm the injection in Chromium
Identifying suspicious JavaScript is not the same as proving a vulnerability. Reading code and guessing what a browser will do is not evidence; browsers are complicated, and a value that looks dangerous in source might be handled safely in practice. So the researcher tested the crafted link in a live headless Chromium browser and inspected the target element's inline style. Inline style means the CSS written directly on the element by JavaScript, which is exactly what the vulnerable code does.
The result was equivalent to:
background: url("https://cdn.example.com/media/profile-photos"), url("https://attacker.example/beacon.png");
Line by line, this is the same two-layer declaration as before: the first layer is the trusted CDN, the second is the attacker's server. Seeing it in the live browser's element style confirmed that the attacker-controlled input had altered the CSS declaration, not just that the string looked odd in the source.
The browser's network activity then showed an outbound request to the external resource. Network activity here means the list of requests the browser made while loading the page, visible in the browser's developer tools or captured by the headless browser. An outbound request is one leaving the page's own site for another server. That second observation was especially important: it demonstrated that the injection produced a real browser-side effect, not just a changed style that the browser ignored.
The complete chain was: the attacker-controlled URL parameter is read by client-side JavaScript, the prefix validation succeeds, the input is concatenated into CSS, the CSS parser creates two background layers, and the browser requests the attacker-controlled resource. Each arrow is a step the researcher could observe, which is what makes the finding solid.
Step 5: Run negative controls
A negative control is a test where you expect the bad thing not to happen, to prove that the bad thing in the main test really depends on the cause you think it does. Without it, you cannot rule out that the site is broken for every input.
The researcher supplied an arbitrary external URL that did not begin with the approved CDN prefix. The application rejected it and no malicious background declaration was inserted. Supplying the injection payload beginning with the trusted prefix made validation pass and the browser loaded the second background-image resource.
The results were:
| Test case | Result |
|---|---|
| Legitimate CDN image URL | Accepted |
| External URL without trusted prefix | Rejected |
| Trusted prefix followed by CSS syntax | Accepted |
| Second CSS background layer | Confirmed |
| External HTTP request | Confirmed |
Reading the table: a normal CDN image is accepted, as it should be. A random outside URL is rejected, which shows the check is doing something. The payload that starts with the trusted prefix is accepted, which shows the check can be fooled. The browser then creates the second background layer and sends the external request, which shows the fooling has a real effect.
This established that the vulnerability was not caused by a complete absence of validation. The guard was working exactly as programmed; the security model behind it was flawed. That distinction matters when reporting: "there is no check" and "the check checks the wrong thing" are different bugs with different fixes.
Step 6: Trace the Base64 deep-link vector
Further analysis showed that the vulnerable value could also originate from the deep_link_sub1 parameter. The application decoded it with logic equivalent to:
function decodeDeepLink(value) { return JSON.parse(atob(value));}
Line by line:
function decodeDeepLink(value) {defines a function nameddecodeDeepLinkthat takes one input,value.atob(value)decodes a Base64 string back into ordinary text. The name means "ASCII to binary", but in practice it turns Base64 into text.JSON.parse(...)turns that text into a JavaScript object, so its fields can be read by name.return ...hands the resulting object back to whoever called the function.}closes the function.
The decoded object could contain a user_photo_url field, for example:
{ "user_photo_url": "https://cdn.example.com/media/profile-photos/avatar.png"}
Line by line:
{starts a JSON object."user_photo_url"is the key, the name of the field.:separates the key from its value."https://cdn.example.com/media/profile-photos/avatar.png"is the value, a normal CDN image address.}closes the object.
That value then flowed into the same variable used by the direct query parameter. Both sources reached the same CSS sink. A sink is the place in the code where data finally gets used in a way that matters, here the .css("background", ...) call. A source is where attacker-controlled data enters, here the query parameters. The report's point is that one vulnerable sink may be reachable through multiple attacker-controlled inputs, so fixing only one source leaves the other open.
The direct query-parameter path was confirmed in the browser; the encoded path was established from the client-side code flow rather than a separately documented browser proof. In other words, the researcher could see from the code that the decoded value reaches the same place, but did not run a separate browser test for that path. Base64 encoding did not make the underlying input trustworthy, it only changed how the input was transported. An everyday comparison: putting a letter in a sealed envelope does not make its contents safe; it only changes how the letter travels.
Root cause
The mistake was using a string-prefix check as a security boundary and then concatenating the same unparsed string into a CSS declaration. startsWith() guarantees only that the value begins with the trusted prefix; it says nothing about the rest of the string, and the CSS parser later interprets characters such as ", ), , and url( with their own meaning. Parsing is the process of reading text according to a grammar and deciding what it means. The CSS parser does not know the text came from a URL check; it only sees CSS.
Validation and final interpretation were not aligned. The existing defence, the prefix check, did not stop the attack because it was never designed to enforce the property the developer intended: that the complete value is a safe URL. The same pattern likely applied to the second page because it shared the JavaScript bundle and the profile-image placeholder, though the strongest runtime evidence came from the social-sharing page. Runtime evidence means evidence from a running browser, as opposed to reading the code.
Impact
The confirmed vulnerability had two primary effects.
First, an attacker could construct a link that caused the victim's browser to request an external resource. When that request reached the attacker-controlled server, the server could observe ordinary request metadata, which depending on browser and network behaviour may include the public IP address, the User-Agent header, the request timestamp and other permitted request headers. In plain words: the attacker's server learns that someone opened the link, roughly where they are from (the IP address), what browser they use, and when. This could be used as a tracking or telemetry beacon, a small signal that a particular person visited a particular page. But the external request did not automatically expose sensitive application data. The request did not establish cookie theft, account compromise or access to authenticated information.
Second, the attacker could alter the CSS background of the profile-image placeholder, gaining influence over part of the page's visual presentation. That could potentially support social engineering by displaying attacker-chosen visual content within an otherwise legitimate page. Social engineering means tricking people rather than machines, for example by making a real page show a fake message or image. But the demonstrated control was limited to the affected CSS background property. The evidence did not establish arbitrary HTML injection or page-wide styling control.
The vulnerability was reflected rather than stored, limited to a CSS background property, triggered by opening a crafted URL, capable of loading an external resource, and capable of modifying the rendered profile-image background. The investigation did not demonstrate JavaScript execution, session hijacking, sensitive-data exfiltration, account takeover, authenticated state changes or server-side code execution. Session hijacking means stealing someone's logged-in session; exfiltration means copying data out; account takeover means getting control of someone's account; server-side code execution means running code on the server itself. None of those were shown.
No session cookies or authentication tokens were stolen and no authenticated actions were performed. This was not cross-site scripting: the browser did not execute an attacker-controlled script. Cross-site scripting (XSS) is when an attacker gets their JavaScript to run in a victim's browser on a site's page; that is a much more serious class of bug, and this report is careful not to claim it.
Fix
The safest fix is to stop treating an arbitrary string as a trusted image URL. The researcher proposed validating the complete URL by parsing it and checking its components:
function isAllowedProfileImage(input) { try { const url = new URL(input);
Line by line:
function isAllowedProfileImage(input) {defines a function that takes a candidate address and will answer yes or no.try {starts a block where errors are caught rather than crashing the page. Ifnew URL(input)fails because the input is not a valid URL, thecatchat the end handles it.const url = new URL(input);parses the input into a URL object, so its parts can be inspected individually.
return ( url.protocol === "https:" && url.origin === "https://cdn.example.com" && url.pathname.startsWith( "/media/profile-photos/" ) && url.username === "" && url.password === "" ); } catch { return false; }}
Line by line:
url.protocol === "https:"requires the scheme to be HTTPS, so plain HTTP is refused.url.origin === "https://cdn.example.com"requires the host to be exactly the trusted CDN.originis scheme plus host plus port, so this cannot be fooled by a lookalike host.url.pathname.startsWith("/media/profile-photos/")requires the path to begin with the expected folder.pathnameis the path part of the URL, without the query string.url.username === ""andurl.password === ""require that no username or password is embedded in the URL. URLs can carry credentials in the formhttps://user:pass@host/, and this refuses that.&&means "and": every condition must be true.return (...)returns the combined true or false answer.} catch {catches any error thrown bynew URL(input).return false;means an unparseable input is refused.}closes the function.
This checks the actual parsed origin rather than trusting the beginning of an unparsed string, and the exact path constraints should be tailored to the application's legitimate image format.
The vulnerable concatenation:
$(".profile-img-placeholder").css( "background", 'url("' + photoUrl + '")');
Line by line, this is the same code as before: it selects the placeholder element and sets its background property to a string built by gluing url(", the value, and "). The problem is the gluing: the value is treated as CSS text.
It should be replaced by a dedicated image element after validating the URL:
const image = document.createElement("img");
Line by line:
document.createElement("img")asks the browser to create a new image element in memory, not yet on the page.const image = ...stores it in a variable so it can be configured next.
if (isAllowedProfileImage(photoUrl)) { image.src = new URL(photoUrl).href;}
Line by line:
if (isAllowedProfileImage(photoUrl))runs the new validation function on the value.image.src = new URL(photoUrl).href;sets the image's source to the parsed, normalised address.hrefis the full URL string of the parsed object.}closes the block.
This avoids interpreting attacker-supplied characters as part of a CSS declaration. An image element's src is a URL, not CSS, so characters like " and ) have no special meaning there.
A restrictive Content Security Policy provides another layer, for example:
Content-Security-Policy: img-src 'self' https:
Line by line:
Content-Security-Policy:is the header name.img-srcis the directive that controls where images may be loaded from.'self'allows images from the same site.https:allows images from any HTTPS source. This is broader than the example above; the report notes that the actual policy must include all legitimate image sources required by the application.
Finally, the same validation rules should be applied to values decoded from Base64 JSON: encoding is not sanitisation, and a value should not become trusted simply because it arrived through an encoded parameter. Sanitisation means cleaning input so dangerous characters cannot do harm; encoding only changes the form of the data, not its meaning.
Variants to test
Here are patterns a researcher can look for on other sites, with what counts as a positive result.
- Other prefix checks feeding CSS sinks. Look for any
startsWith()or regex-anchored check on a URL that is later concatenated into aurl()value. A regex is a pattern for matching text; "anchored" means it is tied to the start or end of the string. A positive result is a value that passes the check and produces a second background layer or an outbound request in the browser. - Other CSS properties built by concatenation. Search the code for
.css()calls that assemble strings from parameters. A positive result is a declaration whose parsed form differs from the intended single value. - Encoded or indirect sources. Test deep-link parameters, Base64 JSON, URL fragments, browser storage and cross-window messages that reach the same sink. A URL fragment is the part after
#in a URL; browser storage is where a site can save data in your browser; cross-window messages are messages passed between browser windows or frames. A positive result is the same injection through a path that bypasses validation applied only to the direct parameter. - Shared bundles across routes. Identify other pages loading the same JavaScript bundle and the same placeholder element. A route is one page or view within a site. A positive result is the same source-to-sink pattern on a second route, ideally confirmed with a separate browser test.
- Negative controls. Always submit an unrelated external URL that should be rejected. A positive result is rejection of the control and acceptance of the trusted-prefix payload, which isolates the exact weakness.
Lessons learned
Security checks can create a false sense of safety: the application contained validation logic, but the logic did not enforce the property the developer intended. Prefix validation is not complete URL validation, and the final parser determines the risk, because input that appears to be a URL may become dangerous when inserted into CSS syntax. Encoded input is still untrusted input. Browser-based evidence matters: the decisive proof was not merely the injected string but the browser's interpretation of it and the resulting network request. Negative controls make findings stronger, and accurate impact assessment is essential. Don't just look for missing validation; look for validation that checks the wrong thing.
Glossary
- Allowlist: a list of things that are permitted, with everything else refused. Here, the trusted CDN prefix.
- Authentication: proving who you are, usually by logging in.
- Base64: a way of writing any data using letters, digits and a few symbols so it can travel safely in text. Not encryption.
- Bundle: one large JavaScript file containing all the code a site needs, often shared across pages.
- CDN (content delivery network): a service that stores and serves files, usually images, from servers around the world.
- Chromium: the open-source browser engine behind Google Chrome, also usable headless.
- Cookie: a small piece of data a site asks your browser to store and send back with requests, often used to remember you are logged in.
- Cross-site scripting (XSS): a bug where an attacker gets their JavaScript to run in a victim's browser on a site's page.
- CSS (Cascading Style Sheets): the language that describes how a page looks.
- CSS injection: a bug where an attacker's text is interpreted as CSS by the victim's browser.
- CSS parser: the part of the browser that reads CSS text and decides what it means.
- Deep link: a link that jumps to a specific place or state inside an app, often carrying data.
- Endpoint: a specific address on a server that accepts requests.
- Exfiltration: copying data out of a system without permission.
- GET: the HTTP method used to ask a server to send something back.
- Header: a labelled line in an HTTP request or response carrying extra information.
- Headless browser: a real browser running without a visible window, controlled by a script.
- HTTP request: the message a browser sends to a server asking for something.
- Inline style: CSS written directly on an element, often by JavaScript.
- JavaScript: the programming language that runs inside your browser and makes pages interactive.
- JSON: a simple text format for structured data using keys and values.
- Negative control: a test where you expect the bad thing not to happen, used to prove the cause of the main result.
- Origin: the combination of scheme, host and port in a URL, such as
https://cdn.example.com. - Outbound request: a request leaving the page's own site for another server.
- Parameter (query parameter): a named value in the URL after the
?. - Parsing: reading text according to a grammar and deciding what it means.
- Placeholder: an empty element on a page reserved to be filled in later, here with the profile image.
- Production: the real, live site that real users use.
- Query string: the part of a URL after
?, holding named values. - Reflected: a vulnerability where the malicious value comes back from the page to the victim's browser and is not stored on the server.
- Regex: a pattern for matching text.
- Route: one page or view within a site.
- Sanitisation: cleaning input so dangerous characters cannot do harm.
- Security boundary: a line the attacker is not supposed to cross.
- Session hijacking: stealing someone's logged-in session to act as them.
- Sink: the place in code where data is finally used in a way that matters.
- Social engineering: tricking people rather than machines.
- Source: where attacker-controlled data enters the code.
- Stored: a vulnerability where the malicious value is saved on the server and served to visitors.
- String concatenation: joining text end to end.
- Token: a secret string that proves who you are, often stored in a cookie or browser storage.
- URL: the address of a resource, made of scheme, host, path and optional query string.
- URL encoding: replacing characters not allowed in a URL with a percent sign and two hex digits.
- User-Agent: a request header telling the server which browser and operating system you use.
- Validation: checking that input meets expected rules before using it.