Skip to content
SQL injection Write-up Intermediate

Protobuf primer

The application was vulnerable to SQL injection in a search endpoint, and the data was serialised with Protobuf and base64. An attacker could inject SQL commands by crafting a serialised Protobuf message, as demonstrated by a custom SQLMap tamper script.

aptw.tf

Published on aptw.tf

Many developers believe that serializing traffic makes a web application more secure, as well as faster. That would be easy, right?

The author, on aptw.tf

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

Impact

An attacker could extract data from the database using blind SQL injection, though the process was slow because SQLMap could not understand the Protobuf-encoded responses.

What the attacker needed

Access to the search endpoint; ability to send crafted Protobuf messages

How it was found

  1. Intercept the search request and notice the payload is base64-encoded Protobuf.
  2. Decode the base64 and deserialise the Protobuf to understand the message structure.
  3. Write a .proto definition and compile it to a Python library.
  4. Use the library to serialise a single quote as the search term, base64-encode it, and send it to the endpoint.
  5. Observe an HTTP 500 error, confirming the SQL injection.
  6. Write a SQLMap tamper script that serialises the payload with Protobuf and base64-encodes it, then run SQLMap with that tamper.

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 app takes a search term, packs it into a binary format called Protobuf, and sends it to the server. The server puts that term directly into a database query without cleaning it, so a malicious term can change the query. This is called SQL injection.

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.