Skip to content
SQL injection Write-up Intermediate

IP spoofing and SQL injection in Textcube

Textcube trusts the Client-IP and X-Forwarded-For headers to set the client's IP address, which is then used unescaped in a SQL query for anonymous sessions. An attacker can spoof their IP with a SQL injection payload to retrieve another user's session identifier or extract arbitrary data from the database.

Sjoerd Langkemper Follow

Published on sjoerdlangkemper.nl

Textcube is a open source blogging application. It contains a SQL injection vulnerability in a HTTP header that is used to determine the client’s IP address.

Sjoerd Langkemper, on sjoerdlangkemper.nl

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The application overwrites the trusted REMOTE_ADDR server variable with an unvalidated HTTP header value and then uses it unescaped in a SQL query.

Impact

An attacker could retrieve the session identifier of another user (including the admin) or extract arbitrary data from the database, but only if the targeted user currently has a valid session.

What the attacker needed

Textcube installed and running; Attacker can send HTTP requests with custom headers; Target user has an active session (for session theft)

How it was found

  1. Set up Textcube locally (e.g., using Docker with Apache and MySQL).
  2. Send a request with a Client-IP header containing a SQL injection payload.
  3. Observe that the response includes a session cookie for another user or database data.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The application believes whatever IP address you put in a special header, instead of checking where the request really came from. It then uses that fake IP in a database query without cleaning it, so an attacker can sneak in database commands. This lets them steal other users' session cookies or read data from the database.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.