Content Spoofing/Text Injection
The search query was reflected on the page without any prefix, allowing an attacker to inject text that appeared as legitimate page content. This could mislead users, for example by displaying false messages.
- Triaged in 8 hours
- Fixed in 9 days
- Paid in 8 hours
- Disclosed after 9 days
Summary by the program
Researcher @ahsantahir reported a content spoofing on the search functionality. The search query was displayed in the page, but without any prefix. We added "Results for:", so nobody can be misinformed.
This has been fixed in the last version and the fix is now deployed.
Thanks for making Gratipay a safer place!
What the report shows
The target was Gratipay's search functionality. The researcher, ahsantahir, found that the search query was reflected back into the page, but with no prefix in front of it. Because the query appeared on its own, the page could be made to read as though it were saying something the site never intended.
The program's summary describes the issue as content spoofing on search. The fix was to add the text "Results for:" before the reflected query, so that a reader can tell the query is user input rather than a statement from the site. The change was made in the last version and deployed; the program links the commit that contains it.
The report records a bounty of 1.00 USD and a low severity. The weakness is classified as a violation of secure design principles. The report does not include the request, the payload, the affected URL or the response, so there is nothing to reproduce here beyond the description above.
Root cause
The report says the search query was displayed in the page without any prefix. A reflected value with no context is indistinguishable from the site's own copy, so whatever the user types is presented as if the application wrote it. Adding a fixed prefix such as "Results for:" gives the value a frame that identifies it as input.
Impact
The search query was shown in the page without a prefix, so a reader could be misinformed. The program's summary says the prefix was added so nobody can be misinformed. The report does not claim script execution, session theft or any other technical consequence; the concern is misleading content shown under the site's identity. That matches the low severity and the design-principle classification.
How this kind of bug works
Content spoofing, sometimes called text injection, happens when user-controlled input is placed into a page in a position where it is read as the application's own content. The browser has no way to tell the difference: text nodes, attribute values and page titles all render the same whether they came from the server's templates or from a query string. If the value is not labelled, a reader attributes it to the site.
The bug class sits next to reflected cross-site scripting but is distinct. XSS needs the input to reach an executable context, such as HTML markup, an event handler or a script block. Content spoofing needs only that the input reach a place a human reads. That makes it easier to trigger and usually lower in severity, but it is still useful for phishing, for fake notices ("your account is suspended, call this number") and for lending the site's authority to a false statement.
The usual defences are contextual output encoding plus a clear label around any reflected value. Encoding stops the input from becoming markup; the label stops it from being mistaken for the site's voice. A Content Security Policy helps against script injection but does nothing for plain text spoofing, which is why the label matters.
How to test for it
- Find every place a value from the URL or a form is shown back to the user: search results pages, error messages, "no results for" notices, login prompts, redirect notices, page titles and 404 pages.
- Send a distinctive marker as the value, for example a short phrase that would be obviously out of place, and load the page in a browser rather than only reading the raw response.
- Look at how the marker is presented. A positive result is the marker appearing as standalone text, a heading, a title or a notice, with nothing around it that identifies it as user input.
- Check the contexts that are easy to miss: the document title, meta refresh targets, the text of error dialogs, and values placed in attributes that are displayed, such as tooltips.
- Confirm the page is served from the target's own origin and that the marker survives any server-side filtering.
Common false positives: the value is already wrapped in quotes or a label ("You searched for ..."), the value is HTML-encoded and shown as inert text inside a clearly marked field, or the reflection only appears in a response the browser never renders. A reflection inside a script or markup context is a different bug class and should be reported as such, not as content spoofing.
How it is fixed
Apply context-aware output encoding so the reflected value cannot become markup. Add a fixed, unambiguous label around any echoed input, so the reader knows the text is theirs. Where the value is not needed in the response, do not reflect it at all. Keep a restrictive Content Security Policy as defence in depth against the script-based variants.
Hunting notes
This bug class tends to hide in search pages, "no results" states, error and validation messages, redirect and logout notices, and any feature that greets the user by a name taken from a parameter. Recon signals include parameters whose values reappear verbatim in the response, pages whose titles change with the query string, and applications that build notices from request data.
To get a report accepted, show the rendered page, not just the raw body, and explain the realistic abuse: a link that displays a false notice under the site's brand. Keep the claim proportionate. If the value also reaches an executable context, report the stronger issue separately and demonstrate it; if it does not, describe the spoofing scenario plainly and let the program judge severity.
What happened, in plain words
Gratipay is a website, and like most websites it has a search box. You type a word into the box, press Enter, and the site shows you a results page. That page has to tell you what you searched for, so it repeats your word back to you.
The researcher, ahsantahir, noticed that the repeated word appeared on the page on its own, with nothing in front of it. That sounds harmless, but it is not quite. The search query was displayed in the page without any prefix.
The program's own summary describes this as content spoofing on the search functionality. The fix was small: the page now puts the text "Results for:" in front of the echoed query. With that label, a reader can see that the words are their own search term rather than a statement from the site. The change was made in the last version and deployed, and the program links the commit that contains it.
The report records a bounty of 1.00 USD and a low severity, and classifies the weakness as a violation of secure design principles. It does not include the request, the payload, the affected URL or the response, so there is nothing to reproduce beyond the description above.
Root cause
The report says the search query was displayed in the page without any prefix. A reflected value with no context is indistinguishable from the site's own copy, so whatever the user types is presented as if the application wrote it. Adding a fixed prefix such as "Results for:" gives the value a frame that identifies it as input.
Impact
The search query was shown in the page without a prefix, so a reader could be misinformed. The program's summary says the prefix was added so nobody can be misinformed. The report does not claim script execution, session theft or any other technical consequence; the concern is misleading content shown under the site's identity. That matches the low severity and the design-principle classification.
How this kind of bug works
In general, content spoofing, sometimes called text injection, happens when user-controlled input is placed into a page in a position where it is read as the application's own content. The browser has no way to tell the difference: text nodes, attribute values and page titles all render the same whether they came from the server's templates or from a query string. If the value is not labelled, a reader attributes it to the site.
The bug class sits next to reflected cross-site scripting but is distinct. XSS needs the input to reach an executable context, such as HTML markup, an event handler or a script block. Content spoofing needs only that the input reach a place a human reads. That makes it easier to trigger and usually lower in severity, but it is still useful for phishing, for fake notices ("your account is suspended, call this number") and for lending the site's authority to a false statement.
The usual defences are contextual output encoding plus a clear label around any reflected value. Encoding stops the input from becoming markup; the label stops it from being mistaken for the site's voice. A Content Security Policy helps against script injection but does nothing for plain text spoofing, which is why the label matters.
How to test for it
- Find every place a value from the URL or a form is shown back to the user: search results pages, error messages, "no results for" notices, login prompts, redirect notices, page titles and 404 pages.
- Send a distinctive marker as the value, for example a short phrase that would be obviously out of place, and load the page in a browser rather than only reading the raw response.
- Look at how the marker is presented. A positive result is the marker appearing as standalone text, a heading, a title or a notice, with nothing around it that identifies it as user input.
- Check the contexts that are easy to miss: the document title, meta refresh targets, the text of error dialogs, and values placed in attributes that are displayed, such as tooltips.
- Confirm the page is served from the target's own origin and that the marker survives any server-side filtering.
Common false positives: the value is already wrapped in quotes or a label ("You searched for ..."), the value is HTML-encoded and shown as inert text inside a clearly marked field, or the reflection only appears in a response the browser never renders. A reflection inside a script or markup context is a different bug class and should be reported as such, not as content spoofing.
How it is fixed
Apply context-aware output encoding so the reflected value cannot become markup. Add a fixed, unambiguous label around any echoed input, so the reader knows the text is theirs. Where the value is not needed in the response, do not reflect it at all. Keep a restrictive Content Security Policy as defence in depth against the script-based variants.
Hunting notes
This bug class tends to hide in search pages, "no results" states, error and validation messages, redirect and logout notices, and any feature that greets the user by a name taken from a parameter. Recon signals include parameters whose values reappear verbatim in the response, pages whose titles change with the query string, and applications that build notices from request data.
To get a report accepted, show the rendered page, not just the raw body, and explain the realistic abuse: a link that displays a false notice under the site's brand. Keep the claim proportionate. If the value also reaches an executable context, report the stronger issue separately and demonstrate it; if it does not, describe the spoofing scenario plainly and let the program judge severity.
Glossary
- Search query: the word or phrase a user types into a search box.
- Reflected value: input that the server sends straight back into the page it returns, instead of storing it.
- Prefix / label: fixed text placed in front of a reflected value (here, "Results for:") so readers know it is their input.
- Request: the message a browser sends to a server asking for a page or action.
- Response: the page or data the server sends back.
- URL: the address of a page, including any parameters after the question mark.
- Parameter: a named value in a URL or form, such as the search term.
- Payload: the specific input an attacker sends to trigger a bug.
- Commit: a saved change in a code repository, identified by a hash.
- Deployed: made live on the production website.
- Bounty: a payment a program gives a researcher for a valid report.
- Severity: how serious a bug is judged to be, here low.
- Secure design principles: the idea that safety should be built into how a feature is designed, not bolted on afterwards.
- XSS (cross-site scripting): a bug where attacker input becomes executable code in a page, letting it run in a victim's browser.
- Executable context: a place in a page where text is treated as code or markup rather than plain text.
- HTML markup: the tags that structure a web page.
- Event handler: an attribute that runs code when something happens, such as a click.
- Script block: a section of a page containing code for the browser to run.
- Output encoding: converting characters so the browser displays them as text instead of interpreting them as markup.
- Content Security Policy (CSP): a header that tells the browser which sources of code are allowed, limiting script injection.
- Phishing: tricking people into trusting a fake message or page, often to steal information.
- Origin: the combination of scheme, host and port that identifies which site a page belongs to.
- False positive: a finding that looks like a bug but is not.
- Meta refresh: a page instruction that redirects the browser to another address after a delay.
- 404 page: the page shown when a requested address does not exist.
- Recon: the early stage of looking around a target to find where input is accepted and shown.
- Defence in depth: layering several protections so one failure does not expose everything.