Breaking Semantica: From Unchecked Graph Imports to Stored Header Injection & Memory DoS
A graph and AI tool interpolated a user-supplied node identifier directly into a download response header, allowing header injection, and also accepted unbounded graph queries that consumed large amounts of memory. An attacker could inject response headers, and could stall the server with a single oversized query.
Cybersecurity
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
Semantica is a graph and AI system, and the write-up concerns its provenance download and graph import features. Provenance downloads let a user retrieve provenance information for a node, and the node identifier is interpolated into the response, including the Content-Disposition header. Graph imports let a user bring graph data into the system, and the identifiers in that data are stored in the database. The report's framing is that such systems concentrate on model logic while ordinary web security issues are left open.
The author reports three vulnerabilities, and pull request #898 in semantica-agi/semantica was merged with fixes for them:
| # | Issue | Weakness | CVSS |
|---|---|---|---|
| 1 | CRLF injection in Content-Disposition |
CWE-113 | 8.2 |
| 2 | Unbounded memory DoS in link enrichment | CWE-770 | 7.5 |
| 3 | Stored attack chain via graph import | CWE-20 + CWE-113 | 8.0 |

The image caption describes pull request #898 as merged, fixing critical RCE, SSRF, XXE and DoS flaws.
Setup
The report does not describe accounts, roles, tools or versions. The report does not describe any preconditions.
Finding it
The starting point is the provenance download. The node_id value is placed directly into the response, and because that response includes a Content-Disposition header, the value ends up inside a response header. A value containing carriage return and line feed characters therefore lets an attacker add headers of their own to the response.
The same identifier is accepted by graph import without sanitisation, so the payload can be written to the database and served back later. That turns what would otherwise be a reflected issue into a stored one.
Separately, the link enrichment query accepts a node and edge count from the caller without a cap. The scoring is O(N²), so a very large count makes the work and the memory use grow far faster than the request size.
Exploitation
Step 1: CRLF injection in the provenance download
The download handler interpolates node_id into the Content-Disposition header. Supplying a value with CRLF sequences splits the header and lets the attacker write arbitrary headers into the response. The report lists three consequences:
- Arbitrary response header injection.
- A
Content-Typeoverride, which leads to XSS. Set-Cookiesession fixation.
The report does not include the literal request or payload used for this step.
Step 2: Memory exhaustion through link enrichment
A query can ask for 999,999 nodes and edges. The scoring is O(N²), so a single request consumes roughly 1.6 GB of RAM and stalls the async event loop. Because the count is unconstrained, the attacker controls how much work and memory each request causes. The report does not include the request itself.
Step 3: Stored attack chain through graph import
Graph imports do not sanitise identifiers. A malicious CRLF payload embedded in an imported identifier is written permanently into the database. From then on, anyone who inspects graph provenance for that node receives the injected headers, with no further action by the attacker. The report describes this as a persistent, zero-click stored attack. It does not include the import payload or the resulting response.
Root cause
There are two distinct mistakes.
- Unsanitised interpolation into a response header.
node_idis treated as safe text and concatenated intoContent-Disposition. Header values must not contain CR or LF, and nothing in the handler enforces that. - No validation at the ingestion boundary. Graph import accepts identifiers as-is, so the same payload that works reflected also persists. The report's remediation points to defensive schema validation at ingestion, which suggests the import path had no such validation.
For the DoS, the enrichment query has no limit cap, so a caller can request an arbitrarily large graph and the O(N²) scoring turns that into memory and event-loop pressure.
Impact
- CRLF injection (8.2): arbitrary response headers,
Content-Typeoverride leading to XSS, andSet-Cookiesession fixation. - Memory DoS (7.5): roughly 1.6 GB of RAM per request and a stalled async event loop, which affects availability for other users of the same process.
- Stored chain (8.0): the payload persists in the database and fires for anyone inspecting graph provenance, with no click required. The report does not quantify how many users or records are affected.
Fix
Pull request #898 was merged, and the report lists three remediation measures. The report lists three remediation measures:
- Whitelist sanitisation for file downloads.
- Strict limit caps with semaphores.
- Defensive schema validation at the ingestion boundary.
Variants to test
- Other header sinks. Look for any parameter that ends up in
Content-Disposition,Location,Set-Cookieor a custom header. A positive result is a response with an extra header you supplied, or a changedContent-Type. - Stored identifiers. Import data whose identifiers contain CRLF and then request the provenance view. A positive result is the injected header appearing on a later, separate request.
- Uncapped counts. Send a very large node and edge count to enrichment-style endpoints. A positive result is a large memory jump or a stalled event loop, visible in latency for concurrent requests.
- Missing concurrency limits. Fire several large requests at once. A positive result is that the semaphore or cap you expect is absent and the process degrades further than a single request would cause.
What happened, in plain words
A researcher named Sunil looked at a piece of software called Semantica. Semantica is a graph and AI system: it stores information as a graph, meaning items (called nodes) connected to each other by links (called edges), and it uses AI techniques on top of that data. The researcher found three security problems in two of its features, and pull request #898 in the project semantica-agi/semantica was merged with fixes.
A pull request is a proposed change to a shared code repository: someone edits the code, submits it, and the maintainers review and merge it. Merging means the change becomes part of the official code.
The two features involved are:
- Provenance downloads. Provenance means the history or origin of something. In this system, a user can download provenance information for a particular node, identified by a value called
node_id. The system builds a file download response and puts the node identifier into it. - Graph imports. A user can bring graph data into the system from outside. The identifiers inside that imported data are then stored in the database.
The author's overall point is that modern AI and graph systems spend a lot of attention on the clever model logic, while ordinary, well-understood web security mistakes are left open. Those ordinary mistakes can create very serious attack surfaces. An attack surface is simply the set of places where an outsider can send input into a system.
The three issues are:
| # | Issue | Weakness | CVSS |
|---|---|---|---|
| 1 | CRLF injection in Content-Disposition |
CWE-113 | 8.2 |
| 2 | Unbounded memory DoS in link enrichment | CWE-770 | 7.5 |
| 3 | Stored attack chain via graph import | CWE-20 + CWE-113 | 8.0 |
A few of those terms need unpacking before we go further.
- CRLF stands for carriage return and line feed. These are the two invisible characters that mark the end of a line of text. In many network protocols, including HTTP (the language browsers and servers use to talk), a line break is meaningful: it separates one header from the next.
- Injection means putting data somewhere the system did not expect data to be interpreted as instructions. If you can slip a line break into a place that is supposed to hold a single line, you can start a new line of your own.
- CWE is a catalogue of common weakness types, a shared naming system for classes of bug. CWE-113 is the entry for improper neutralisation of CRLF sequences in HTTP headers. CWE-770 is the entry for allocation of resources without limits or throttling. CWE-20 is the entry for improper input validation.
- CVSS is a scoring system that rates the severity of a vulnerability, roughly from 0 to 10. Higher is worse.
- DoS means denial of service: making a system unavailable to its legitimate users, for example by exhausting its memory.

The image caption describes pull request #898 as merged, fixing critical RCE, SSRF, XXE and DoS flaws. RCE means remote code execution (an attacker running their own code on the server), SSRF means server-side request forgery (tricking the server into making requests on the attacker's behalf), and XXE means XML external entity (abusing how a server parses XML documents). Those are the categories named in the pull request description; the three findings below are the ones the write-up itself walks through.
Before you start: what you need to know
You do not need any special tools to follow this. You need to understand a handful of everyday web concepts.
- A request and a response. When you type an address into a browser, the browser sends a request to a server, and the server sends back a response. The response has two parts: headers, which are small labelled lines of metadata, and a body, which is the actual content (a web page, a file, an image).
- A header. Think of headers as the label on a parcel: they say what is inside, who sent it, and how it should be handled.
Content-Typesays what kind of content the body is (for example, a web page or a file download).Content-Dispositionsays whether the browser should display the content inline or treat it as a download, and what filename to suggest.Set-Cookietells the browser to store a small piece of data. - A cookie. A cookie is a small piece of data a website asks your browser to keep and send back on every later request to that site. It is how a site remembers that you are logged in. If an attacker can make your browser store a cookie of their choosing, that is called session fixation: the attacker fixes your session identifier to a value they know, and can then take over the session.
- XSS, cross-site scripting, is when an attacker gets their own code (usually JavaScript) to run inside another user's browser in the context of a trusted site. Overriding
Content-Typecan help with this: if a response that should be treated as a plain file is instead treated as a web page, the browser may execute what is inside it. - An API is the part of a system that other software talks to, rather than a human clicking buttons. Think of a restaurant: the menu and the waiter are the API. You say what you want in a defined way, and the kitchen does the work. Here, the provenance download and the graph import are features that a client program calls with parameters such as
node_id. - A database is where the system keeps its data permanently, so it survives restarts. Anything written there stays until something deletes it.
- Sanitisation (or sanitising) means cleaning input so that dangerous characters cannot do anything harmful, for example by removing or escaping line breaks. Validation means checking that input matches what is expected at all, and rejecting it if not. A whitelist is a list of what is allowed; anything not on the list is refused.
- An event loop is how many modern servers handle many requests at once without needing a separate thread for each one. The server keeps a single loop that picks up work items and runs them one after another. If one item takes a very long time, everything else waits behind it. That is what stalling the event loop means.
- O(N²) is a way of describing how the amount of work grows with the size of the input. N is the number of items. O(N²) means that if you double the number of items, the work roughly quadruples; if you multiply the items by ten, the work grows about a hundredfold. It gets out of hand quickly.
- A semaphore is a simple counting mechanism used to limit how many things can happen at the same time. Picture a car park with a fixed number of spaces and a barrier: once the spaces are full, further cars wait outside. In software, a semaphore caps concurrent work so that a flood of requests cannot all run at once.
The setup
The write-up does not describe accounts, roles, tools or software versions. The report does not describe any preconditions.
In other words: the attacker needs to be able to send requests to those two features, and for the third finding, somebody else needs to look at the affected node's provenance afterwards.
Finding it
The starting point is the provenance download. The node_id value supplied by the caller is placed directly into the response, and because that response includes a Content-Disposition header, the value ends up inside a response header. If the value contains carriage return and line feed characters, the attacker can therefore add headers of their own to the response.
Here is the everyday comparison. Imagine a form where you write your name, and the clerk copies whatever you write straight onto a label, one line per field. If you write your name and then press Enter and write a second line, the clerk's label now has an extra line that looks like a separate field. The system trusted the input to be a single line and never checked.
The same identifier is accepted by graph import without sanitisation, so the payload can be written to the database and served back later. That turns what would otherwise be a reflected issue into a stored one. A reflected issue only affects the person who sends the malicious input, in that one response. A stored issue is saved on the server and affects anyone who later views the saved data.
Separately, the link enrichment query accepts a node and edge count from the caller without a cap. Link enrichment is the step that scores the connections between nodes. The scoring is O(N²), so a very large count makes the work and the memory use grow far faster than the size of the request. A tiny request can therefore ask for an enormous amount of computation.
Exploitation
Step 1: CRLF injection in the provenance download
The download handler interpolates node_id into the Content-Disposition header. Interpolate here means simply inserting the value into a larger piece of text, the way a mail merge inserts a name into a template letter. Supplying a value with CRLF sequences splits the header and lets the attacker write arbitrary headers into the response.
Why does splitting work? HTTP headers are lines of the form Name: value, and the end of a line is marked by CRLF. The server intends to send one header:
If node_id contains a CRLF followed by more text, the server sends that extra text as a new line, and the browser reads it as a new header. The attacker has effectively added lines to the server's reply.
The report lists three consequences:
- Arbitrary response header injection. The attacker can add any header they like to the response.
- A
Content-Typeoverride, which leads to XSS. By adding their ownContent-Type, the attacker can change how the browser interprets the body, for example from a downloadable file to a web page whose script then runs. Set-Cookiesession fixation. By adding aSet-Cookieheader, the attacker can make the victim's browser store a session identifier chosen by the attacker.
The report does not include the literal request or payload used for this step.
Step 2: Memory exhaustion through link enrichment
A query can ask for 999,999 nodes and edges. The scoring is O(N²), so a single request consumes roughly 1.6 GB of RAM and stalls the async event loop. Because the count is unconstrained, the attacker controls how much work and memory each request causes.
Why is this so damaging? RAM is the working memory of the server. 1.6 GB for one request is a large share of a typical server's memory. And because the event loop is single and shared, while it is busy with this one enormous calculation, other users' requests sit waiting. It is like one customer at a shop counter asking the assistant to count a million items one by one while everyone else queues behind them.
The report does not include the request itself.
Step 3: Stored attack chain through graph import
Graph imports do not sanitise identifiers. A malicious CRLF payload embedded in an imported identifier is written permanently into the database. From then on, anyone who inspects graph provenance for that node receives the injected headers, with no further action by the attacker. The report describes this as a persistent, zero-click stored attack: persistent because it stays in the database, zero-click because the victim does not have to click anything, they only have to view the provenance.
This is why the third finding is called a chain. The import feature is used to plant the payload (the first link), and the download feature later delivers it to a victim (the second link). Neither feature alone would be as serious; together they turn a one-off trick into a trap that waits for visitors.
The report does not include the import payload or the resulting response.
Root cause
There are two distinct mistakes.
- Unsanitised interpolation into a response header.
node_idis treated as safe text and concatenated intoContent-Disposition. Header values must not contain CR or LF, and nothing in the handler enforces that. - No validation at the ingestion boundary. The ingestion boundary is the point where outside data enters the system, here the graph import. Graph import accepts identifiers as-is, so the same payload that works reflected also persists. The report's remediation points to defensive schema validation at ingestion, which suggests the import path had no such validation. A schema is a description of the expected shape of data; validating against it means rejecting anything that does not fit.
For the DoS, the enrichment query has no limit cap, so a caller can request an arbitrarily large graph and the O(N²) scoring turns that into memory and event-loop pressure. Concurrency control is the mechanism that limits how many operations run at the same time, the semaphore described earlier.
Impact
- CRLF injection (8.2): arbitrary response headers,
Content-Typeoverride leading to XSS, andSet-Cookiesession fixation. - Memory DoS (7.5): roughly 1.6 GB of RAM per request and a stalled async event loop, which affects availability for other users of the same process.
- Stored chain (8.0): the payload persists in the database and fires for anyone inspecting graph provenance, with no click required. The report does not quantify how many users or records are affected.
Fix
Pull request #898 was merged, and the report lists three remediation measures. The report lists three remediation measures:
- Whitelist sanitisation for file downloads. Only characters and values on an approved list are allowed through, so line breaks and other dangerous characters cannot reach the header.
- Strict limit caps with semaphores. The enrichment query refuses counts above a sensible maximum, and a semaphore limits how many such operations can run at once, so no single caller can monopolise the server.
- Defensive schema validation at the ingestion boundary. Imported data is checked against an expected shape before it is stored, so malicious identifiers are rejected at the door rather than saved.
Variants to test
If you are learning to look for these classes of bug, here are the same ideas applied more widely. Each one is a way of asking the same question: does untrusted input reach a place where it is treated as instructions?
- Other header sinks. A sink is a place where data ends up and is interpreted. Look for any parameter that ends up in
Content-Disposition,Location,Set-Cookieor a custom header. A positive result is a response with an extra header you supplied, or a changedContent-Type. - Stored identifiers. Import data whose identifiers contain CRLF and then request the provenance view. A positive result is the injected header appearing on a later, separate request.
- Uncapped counts. Send a very large node and edge count to enrichment-style endpoints. An endpoint is a specific address on a server that accepts requests. A positive result is a large memory jump or a stalled event loop, visible in latency for concurrent requests. Latency is how long a request takes to get a response.
- Missing concurrency limits. Fire several large requests at once. A positive result is that the semaphore or cap you expect is absent and the process degrades further than a single request would cause.
Glossary
- API: the part of a system that other software talks to, with defined inputs and outputs, rather than a human clicking buttons.
- Attack surface: all the places where an outsider can send input into a system.
- Concurrency control: a mechanism that limits how many operations run at the same time.
- Cookie: a small piece of data a website asks your browser to store and send back on later requests, commonly used to keep you logged in.
- CRLF: carriage return and line feed, the two invisible characters that mark the end of a line of text.
- CVSS: a scoring system that rates vulnerability severity, roughly from 0 to 10, higher being worse.
- CWE: a catalogue of common weakness types, a shared naming system for classes of bug.
- DoS (denial of service): making a system unavailable to its legitimate users, for example by exhausting its memory.
- Edge: in a graph, a link connecting two items.
- Endpoint: a specific address on a server that accepts requests.
- Event loop: the single loop a server uses to pick up and run work items one after another; a long item stalls everything behind it.
- Graph: a way of storing data as items (nodes) connected by links (edges).
- Header: a small labelled line of metadata in a request or response, such as
Content-TypeorContent-Disposition. - Ingestion boundary: the point where outside data enters a system.
- Injection: putting data somewhere the system did not expect it to be interpreted as instructions.
- Interpolation: inserting a value into a larger piece of text, like a mail merge.
- Latency: how long a request takes to get a response.
- Link enrichment: the step that scores the connections between nodes in the graph.
- Node: an item in a graph.
- O(N²): a description of work that grows with the square of the input size, so doubling the input roughly quadruples the work.
- Provenance: the history or origin of a piece of data.
- Pull request: a proposed change to a shared code repository, reviewed and merged by maintainers.
- RAM: the working memory of a server or computer.
- RCE (remote code execution): an attacker running their own code on a server.
- Reflected: a vulnerability that only affects the person who sends the malicious input, in that one response.
- Sanitisation: cleaning input so dangerous characters cannot do anything harmful.
- Schema: a description of the expected shape of data.
- Semaphore: a counting mechanism that caps how many things can happen at the same time, like a car park barrier.
- Session fixation: an attack where the attacker fixes a victim's session identifier to a value they know, so they can take over the session.
- Sink: a place where data ends up and is interpreted.
- SSRF (server-side request forgery): tricking a server into making requests on the attacker's behalf.
- Stored: a vulnerability whose payload is saved on the server and affects anyone who later views the saved data.
- Validation: checking that input matches what is expected and rejecting it if not.
- Whitelist: a list of what is allowed; anything not on the list is refused.
- XSS (cross-site scripting): getting an attacker's code to run inside another user's browser in the context of a trusted site.
- XXE (XML external entity): abusing how a server parses XML documents to make it read files or make requests it should not.
- Zero-click: an attack that needs no action from the victim beyond viewing the affected content.