Lack of sanitization of the billing address in pdf invoice
The billing address field was not sanitised before being inserted into a PDF invoice, allowing HTML code injection. An attacker could inject HTML into the generated PDF, though the PDF backend was isolated from payment infrastructure and could not access sensitive information.
- Triaged in under an hour
- Fixed in 20 hours
- Paid in 19 hours
- Disclosed after 8 months
Summary by the program
Adam identified a vulnerability that allowed the HTML code injection into payment invoice PDFs. This vulnerability arose from insufficient content sanitization during the interaction between services, where considered trustworthy content from the user service was transferred to the invoice generation system without proper validation. It's important to note that the PDF generation backend operates in isolation from the payment infrastructure. As a result, it does not have the capability to access sensitive information. The subsequent internal review revealed no evidence of this vulnerability being exploited by unauthorized parties.
What the report shows
The target is the Semrush bug bounty programme on HackerOne, scoped to *.semrush.com. The researcher, a_d_a_m, reported a vulnerability that the programme summarised as HTML code injection into payment invoice PDFs. The weakness was classified as Server-Side Request Forgery (SSRF) and rated high severity. The report was disclosed on 6 March 2024. No bounty amount and no CVSS score are given.
The feature involved is invoice generation. According to the programme's summary, the invoice PDFs are produced by a separate backend that takes content originating from the user service. Content originating from the user service is carried into that invoice generation system, and the content is not sanitised on the way.
In the programme's own account, the researcher identified that this lack of sanitisation allowed HTML code to be injected into the generated payment invoice PDFs. The report as published does not include the request, the payload, the parameter name or the resulting PDF, so the exact injection point and syntax are not shown here.
The programme describes the cause as insufficient content sanitisation during the interaction between services: content from the user service was considered trustworthy and transferred to the invoice generation system without proper validation.
The programme also states two containment points. The PDF generation backend runs in isolation from the payment infrastructure, so it cannot reach sensitive information. A subsequent internal review found no evidence that the vulnerability had been exploited by unauthorised parties.
The published text does not describe a fix, a remediation timeline or a retest.
Root cause
The mistake the report points to is a broken trust boundary between two internal services. The user-facing service accepts data that the user controls and passes it onward to the invoice generator as if it were already safe. The invoice generator then renders that data into a PDF without sanitising it, so markup supplied by the user is interpreted rather than displayed as text.
In general terms, the receiving service treats input from a sibling service as trusted, and the sending service does not neutralise the content before forwarding it. The report does not identify which component performed the PDF rendering or how the injected markup was interpreted, so the precise mechanism inside the generator is not stated.
Impact
The programme frames the impact as HTML code injection into payment invoice PDFs. Because the PDF backend is isolated from the payment infrastructure, the programme states that it cannot access sensitive information, which limits the blast radius compared with an injection that reaches payment systems directly.
The report does not describe what an attacker could achieve with the injected HTML beyond it appearing in the invoice, for example whether scripts execute in a viewer, whether external resources are fetched, or whether the invoice content can be altered to mislead a recipient. Those possibilities are not claimed here.
How this kind of bug works
Injection into generated documents happens when user-controlled data is placed into a markup or template language without context-aware encoding. A PDF generator typically renders an HTML template through a headless browser or an HTML-to-PDF library. If user-controlled data is inserted into that template as raw markup, characters that the template engine treats as structure, such as angle brackets and attribute syntax, become part of the document instead of literal text.
The same class of flaw often has a second face. If the renderer fetches remote resources referenced by the markup, such as images, stylesheets or fonts, an attacker who can inject a URL can make the backend issue a request to a destination of their choosing. That is why a document injection can be classified as SSRF: the renderer becomes a request proxy. Whether that happened in this case is not stated in the report.
Defences are layered. The first is output encoding at the point of interpolation, so that user data is escaped for the context it lands in. The second is input validation on fields that have a known shape, such as postal addresses. The third is to treat service-to-service traffic as untrusted, applying the same validation on the receiving side as on the public edge. The fourth is to restrict what the renderer can reach on the network, so that even successful injection cannot turn into a request to internal services.
How to test for it
- Find the fields that flow into the document. Billing and shipping addresses, company names, VAT numbers, notes and custom line-item descriptions are common carriers.
- Submit a benign marker first, such as a distinctive word, and confirm it appears in the generated document. This establishes the data path before you test for injection.
- Send markup that would be visible if interpreted but harmless if escaped, for example a bold tag or an italic tag around the marker. Retrieve the document and inspect whether the formatting took effect or the literal characters were printed.
- If markup is interpreted, escalate carefully within the programme's rules: test whether attribute injection is possible, and whether the renderer resolves external references by pointing an image or stylesheet at a host you control and watching for the incoming request.
- Record the exact request, the exact payload, the generated document and any callback you received. A positive result is a document whose rendering changed because of your input, or an out-of-band request triggered by the renderer.
Common false positives: the marker appearing as escaped text is not a finding; a PDF viewer rendering a link that you supplied as plain text is not injection; and a request you observe from your own browser rather than from the backend is not SSRF. Confirm the source of any callback by checking its timing and origin against the document generation event.
How it is fixed
Apply context-aware output encoding wherever user data is interpolated into the document template, so that markup characters are escaped. Validate fields with a known format on the service that accepts them, and repeat that validation on the service that consumes them rather than trusting the caller. Where the renderer can fetch remote resources, restrict it to an allowlist of destinations and block private address ranges and internal hostnames. Run the document generator in a network segment that cannot reach sensitive systems, which is the containment the programme describes here.
Hunting notes
Document generation is a good place to look because it sits at the seam between two services, and seams are where validation is often assumed rather than performed. Recon signals include features that produce downloadable PDFs, email attachments or printable views, and any indication that a separate rendering service exists, such as distinct error pages, rendering delays or template-specific quirks.
Fields that are rarely exercised in testing, such as secondary addresses, company details and free-text notes, are worth more attention than the primary name field. Test the same value through every path that reaches the document, including profile updates, imports and API endpoints, since one path may sanitise and another may not.
To make a report land, show the full chain: the request that stored the payload, the document that rendered it, and, where relevant, the callback proving the backend made the request. State clearly what the renderer could reach, because containment often decides the severity. If the generator is isolated, say so and describe the realistic impact rather than implying access to payment or customer data.
What happened, in plain words
Semrush is an online service for search and marketing data. Like most paid services, it produces invoices: PDF documents that show what a customer was charged and where the bill was sent.
A researcher called a_d_a_m reported that content from the user service was not cleaned before it reached the invoice PDF generation. The programme's summary calls the result HTML code injection into payment invoice PDFs. The weakness was classified as Server-Side Request Forgery (SSRF) and rated high severity. The report was disclosed on 6 March 2024. No bounty amount and no CVSS score are given.
To follow this, you need three ideas:
- HTML is the language web pages are written in. It uses tags such as
<b>to mark structure and formatting. A browser reads those tags and shows bold text instead of the literal characters. - Sanitising means cleaning user input so that characters with a special meaning, like
<and>, are turned into harmless text before they are stored or displayed. - A PDF invoice generator is a separate piece of software that takes a template, fills in the customer's details, and produces the finished PDF. Many such generators work by rendering an HTML template, the same way a browser would.
The feature involved is invoice generation. According to the programme's summary, the invoice PDFs are produced by a separate backend that takes content originating from the user service. Content originating from the user service is carried into that invoice generation system, and the content is not sanitised on the way.
A simple comparison: imagine a receptionist who writes down what visitors say and passes the note to a printer. If a visitor says "print this in red", a careful receptionist writes the words down as a sentence. A careless one passes the instruction on, and the printer obeys it. Here the user service was the careless receptionist and the invoice generator was the printer.
The programme describes the cause as insufficient content sanitisation during the interaction between services: content from the user service was considered trustworthy and transferred to the invoice generation system without proper validation. In other words, content from the user service was considered trustworthy and passed to the invoice generation system without proper validation.
The report as published does not include the request, the payload, the parameter name or the resulting PDF, so the exact injection point and syntax are not shown here.
The programme also states two containment points. The PDF generation backend runs in isolation from the payment infrastructure, so it cannot reach sensitive information. A subsequent internal review found no evidence that the vulnerability had been exploited by unauthorised parties. The published text does not describe a fix, a remediation timeline or a retest.
Why the classification matters
SSRF stands for Server-Side Request Forgery. It means that an attacker can make a server send a request to a destination the attacker chooses. A document renderer can become such a proxy: if the markup it processes refers to an image or a stylesheet at some URL, the renderer may go and fetch it. That fetch comes from the server, not from the attacker's browser, so it can reach places the attacker cannot.
Whether that happened in this case is not stated in the report. The programme frames the impact as HTML code injection into the invoice PDFs, and says the isolated backend limits what could be reached. The report does not describe what an attacker could achieve with the injected HTML beyond it appearing in the invoice, for example whether scripts execute in a viewer, whether external resources are fetched, or whether the invoice content can be altered to mislead a recipient.
In general, how this kind of bug works
Injection into generated documents happens when user-controlled data is placed into a markup or template language without context-aware encoding. A PDF generator typically renders an HTML template through a headless browser or an HTML-to-PDF library. If user-controlled data is inserted into that template as raw markup, characters that the template engine treats as structure, such as angle brackets and attribute syntax, become part of the document instead of literal text.
The same class of flaw often has a second face. If the renderer fetches remote resources referenced by the markup, such as images, stylesheets or fonts, an attacker who can inject a URL can make the backend issue a request to a destination of their choosing. That is why a document injection can be classified as SSRF: the renderer becomes a request proxy.
Defences are layered:
- Output encoding at the point of interpolation, so that user data is escaped for the context it lands in.
- Input validation on fields that have a known shape, such as postal addresses.
- Treating service-to-service traffic as untrusted, applying the same validation on the receiving side as on the public edge.
- Restricting what the renderer can reach on the network, so that even successful injection cannot turn into a request to internal services.
How to test for it
- Find the fields that flow into the document. Billing and shipping addresses, company names, VAT numbers, notes and custom line-item descriptions are common carriers.
- Submit a benign marker first, such as a distinctive word, and confirm it appears in the generated document. This establishes the data path before you test for injection.
- Send markup that would be visible if interpreted but harmless if escaped, for example a bold tag or an italic tag around the marker. Retrieve the document and inspect whether the formatting took effect or the literal characters were printed.
- If markup is interpreted, escalate carefully within the programme's rules: test whether attribute injection is possible, and whether the renderer resolves external references by pointing an image or stylesheet at a host you control and watching for the incoming request.
- Record the exact request, the exact payload, the generated document and any callback you received. A positive result is a document whose rendering changed because of your input, or an out-of-band request triggered by the renderer.
Common false positives: the marker appearing as escaped text is not a finding; a PDF viewer rendering a link that you supplied as plain text is not injection; and a request you observe from your own browser rather than from the backend is not SSRF. Confirm the source of any callback by checking its timing and origin against the document generation event.
How it is fixed
Apply context-aware output encoding wherever user data is interpolated into the document template, so that markup characters are escaped. Validate fields with a known format on the service that accepts them, and repeat that validation on the service that consumes them rather than trusting the caller. Where the renderer can fetch remote resources, restrict it to an allowlist of destinations and block private address ranges and internal hostnames. Run the document generator in a network segment that cannot reach sensitive systems, which is the containment the programme describes here.
Where to look
Document generation is a good place to look because it sits at the seam between two services, and seams are where validation is often assumed rather than performed. Signals worth watching for include features that produce downloadable PDFs, email attachments or printable views, and any indication that a separate rendering service exists, such as distinct error pages, rendering delays or template-specific quirks.
Fields that are rarely exercised in testing, such as secondary addresses, company details and free-text notes, are worth more attention than the primary name field. Test the same value through every path that reaches the document, including profile updates, imports and API endpoints, since one path may sanitise and another may not.
To make a report land, show the full chain: the request that stored the payload, the document that rendered it, and, where relevant, the callback proving the backend made the request. State clearly what the renderer could reach, because containment often decides the severity. If the generator is isolated, say so and describe the realistic impact rather than implying access to payment or customer data.
Glossary
- HTML: the markup language used to structure web pages and many document templates; tags such as
<b>carry formatting meaning. - HTML code injection: a flaw where user input containing markup is interpreted as structure by the system that displays it, instead of being shown as plain text.
- Sanitisation: cleaning input so that characters with special meaning are neutralised before the data is stored, forwarded or rendered.
- Output encoding: converting user data into a safe form for the exact place it is inserted, so it cannot break out of that context.
- Input validation: checking that data matches an expected shape or format before accepting it.
- Trust boundary: the line between components that trust each other and those that do not; data crossing it should be re-checked.
- Service-to-service traffic: requests exchanged between internal components of an application, rather than between a user's browser and the public site.
- PDF generator: software that fills a template with data and produces a finished PDF, often by rendering HTML.
- Headless browser: a browser engine run without a visible window, used by servers to render pages or documents.
- SSRF (Server-Side Request Forgery): a flaw that lets an attacker make a server send a request to a destination of the attacker's choosing.
- Callback: an incoming request to a server the tester controls, used as proof that another system made the request.
- Allowlist: an explicit list of permitted destinations or values; anything not on the list is refused.
- Blast radius: the extent of what an attacker could reach or damage if a flaw is exploited.
- False positive: a test result that looks like a finding but is not one.
- CVSS: a standard scoring system for rating the severity of vulnerabilities.