Skip to content
SQL injection Write-up Beginner

Shodan is your friend!!! If you ignore him you will lose many…

An internet-exposed login page on a cloud-hosted IP belonging to the organisation was vulnerable to SQL injection in the authentication form, allowing the attacker to log in as admin. Once inside, the attacker could view developer profiles and project files.

Vijaysimha Reddy Bathini Follow

Published on medium.com

In this blog post, I would like to tell you about my recent finding and it will also show you how effective can be. As it is my first writeup please ignore all my grammatical errors.

Vijaysimha Reddy Bathini, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 3 min read.

Context

This is a short account of how a recon-first approach led to a critical authentication bypass on a public bug bounty program. The program is referred to throughout as redacted.com. The report does not name the program, the organisation, the affected host or the application.

The target was not one of the program's in-scope domains. It was an IP address whose certificate belonged to the organisation, hosting a service that presented a basic authentication page carrying the organisation's logo. Behind that login sat developer profiles and project files. The weakness reported was SQL injection leading to authentication bypass.

From the original on medium.com

Setup

The researcher had spent the preceding couple of months working only on reconnaissance, having stopped hunting for a period, on the reasoning that without recon you end up collecting duplicates. No specific tooling beyond Shodan is described, and no accounts, roles or versions are given.

The program had a wide scope and had rewarded almost 600 vulnerabilities, which made the in-scope domains look picked over. The organisation's own IP space, including what it hosts with cloud providers, was the less obvious surface.

Finding it

The starting point was Shodan. A query on the organisation name returned roughly 400 results:

Text
org:" redacted"

The org filter returns the IPs that belong to the organisation. Fourteen of the results were checked by hand and nothing was found, at which point the researcher stopped.

A couple of hours later the next idea was whether the organisation hosts services on cloud providers such as Amazon cloud or Google Cloud. A Shodan dork was run against every cloud service provider. The key point in the report is the difference between the two filters: org only covers IPs registered to the organisation, so to also catch IPs the organisation hosts on a cloud provider you filter on the certificate instead:

Text
ssl:"organization name"

This surfaced an IP whose certificate belonged to the organisation. Opening the IP confirmed it: the page carried the organisation's logo. It was a basic authentication page, and the immediate thought on seeing a login page was authentication bypass through SQL injection.

Exploitation

Step 1: Bypass the login

The credentials entered were username admin and the password below:

Text
'OR 1=1 -- +

The login succeeded and the researcher was logged in as admin. The report does not show the underlying request, the server response or the query that was built.

Step 2: What was behind the login

The domain exposed some developer profiles and their project files. Rather than assume those developers worked for the organisation, the researcher searched for them on GitHub and LinkedIn and confirmed the affiliation that way. At that point the finding was judged sufficient to report.

Root cause

Why the existing defences did not stop it is not stated.

Impact

The researcher logged in as admin and reached developer profiles and project files. The finding depended on the host being discoverable through its certificate and on the login form being vulnerable.

Fix

Variants to test

  1. Repeat the certificate-based search for other organisations: run the ssl:"organization name" query and open each result, looking for login pages carrying the organisation's branding. A positive result is a host that is not in the published scope but clearly belongs to the target.
  2. On every basic authentication page found this way, try the same tautology in the password field. A positive result is a successful login as admin.
  3. Compare org: and ssl: results for the same organisation to find cloud-hosted assets that the org filter misses.
  4. After any bypass, enumerate what the session exposes, such as user profiles and project files, and verify staff affiliation through public sources before reporting.

Timeline

The report was submitted to redacted, triaged within 30 minutes, and rewarded in less than 3 hours.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

A security researcher found a serious weakness in a website belonging to a large company, and the way he found it is the interesting part. He did not start by poking at the websites the company had officially listed as fair game. He started by looking for computers the company owned, using a public search engine for internet-connected devices called Shodan.

Once he found one of those computers, it showed a login box with the company's logo on it. He typed a special password into that box, one that tricks the login check into saying yes to anyone, and he was let in as the administrator. Behind the login were profiles of the company's developers and their project files.

He reported it, it was triaged within 30 minutes, and he was rewarded in less than three hours. The report does not say how much.

From the original on medium.com

The idea behind the approach

Before this finding, the researcher had spent a couple of months doing nothing but reconnaissance. Reconnaissance (often shortened to recon) means gathering information about a target before attacking it: what computers it owns, what services they run, what software versions they use, what names appear on their certificates. It is the opposite of guessing.

His reasoning was simple. If you skip recon and just try random tricks on the obvious websites, you will keep finding the same bugs that hundreds of other people have already found and reported. Bug bounty platforms pay the first person to report a bug, so a duplicate earns nothing. Good recon is what puts you in front of something nobody else has looked at.

He also quoted a line he attributes to Zseano: a program with a bigger scope has a higher probability of containing a bug than a small one. Scope means the list of systems a company has authorised researchers to test. A wide scope means more places to look, and therefore more chance that at least one of them is weak.

Why the obvious targets looked hopeless

The program he was working on had a wide scope, but it had already rewarded almost 600 vulnerabilities. That number is the important detail: it tells you that a lot of people have already been through the listed websites. The researcher assumed he would not find anything there.

So he changed the question. Instead of asking "which websites are in scope?", he asked "which computers does this company own?". A company's own machines, including ones it rents from cloud providers, may not be on the official scope list at all.

Throughout the write-up the company is called redacted.com, because the program's name is not public.

Step 1: Searching Shodan by organisation

Shodan is a search engine, but instead of indexing web pages it indexes devices connected to the internet. It records what each device answers with, including the text on its certificate (explained below). You search it with filters, a bit like searching a database.

The first query was:

Text
org:" redacted"

Line by line:

  • org: is a Shodan filter. It restricts results to IP addresses that are registered to a particular organisation. An IP address is the numeric address of a computer on the internet, like a postal address for a machine.
  • " redacted" is the organisation name in quotes. The quotes tell Shodan to treat the words as one exact phrase rather than separate keywords.

This returned roughly 400 results. Four hundred machines is far too many to inspect by hand, so he checked 14 of them, found nothing, and stopped. That is a reasonable decision: recon is about coverage, but you still have to spend your time where it pays.

Step 2: The better question, cloud hosting

A couple of hours later he had a new thought. Does this company host services on cloud providers such as Amazon cloud or Google Cloud?

This matters because of how the org filter works. It only returns IP addresses that are registered to the organisation itself. If a company rents a server from a cloud provider, that server's IP address is usually registered to the cloud provider, not to the company. So the org search silently misses all of it.

His answer was to search on something the company cannot avoid putting on its own servers: the certificate.

A certificate (more precisely a TLS/SSL certificate) is what lets your browser show the padlock and prove that a website really belongs to who it claims. When a company sets up a server, the certificate on it usually carries the company's name. Shodan records that name, so you can search for it even when the IP address belongs to somebody else.

The query was:

Text
ssl:"organization name"

Line by line:

  • ssl: is a Shodan filter that searches the contents of certificates seen on a device, rather than the registered owner of the IP address.
  • "organization name" is the name to look for inside those certificates, again as an exact phrase.

He ran this kind of search against every cloud service provider. The difference between the two queries is the whole lesson of the article: org finds what the company owns outright, ssl also finds what the company runs on somebody else's hardware.

Step 3: Confirming the target

One of the results was an IP address whose certificate carried the organisation's name. That is a strong hint but not proof, so he opened the IP address in a browser. The page showed the organisation's logo. That confirmed it: this machine belonged to the target.

What he saw was a basic authentication page. Basic authentication is the simplest kind of login: the browser itself pops up a small box asking for a username and password, rather than the site showing a nicely designed login form. It is common on internal tools, admin panels and devices.

Step 4: The login bypass

When he saw a login box, his first thought was authentication bypass through SQL injection. Two terms to unpack here.

Authentication is the process of proving who you are, normally with a username and password. Authentication bypass means getting past that check without knowing the real password.

SQL is the language databases use to store and retrieve data. A typical application checks a login by asking the database a question like "is there a user called admin whose password is this?". SQL injection (SQLi) means putting SQL code into an input field, such as the password box, so that the application accidentally treats your text as part of its own database question instead of as plain data.

A useful comparison: imagine a form where you fill in "name" and the clerk reads out "find the person named [your text]". If you write your name as nobody, or anyone at all, the clerk reads "find the person named nobody, or anyone at all" and hands you the first record in the filing cabinet. You did not lie about being that person; you changed the question.

He entered the username admin and this password:

Text
'OR 1=1 -- +

Line by line:

  • ' is a single quote. In SQL, quotes mark the beginning and end of a piece of text. Putting one in closes the text early, so whatever follows is read as SQL code rather than as part of the password.
  • OR is a SQL keyword that makes a condition true if either side is true.
  • 1=1 is a statement that is always true. One equals one, always. So the whole condition becomes true no matter what the real password is.
  • -- starts a comment in SQL. Everything after it is ignored, which is how the rest of the original query (the part that would check the password) is thrown away.
  • + is how a space is often encoded in a URL. It is there so the comment marker is followed by a space and the database parses it correctly.

The login succeeded and he was logged in as admin. The report does not show the request the browser sent, the server's response, or the database query that was built, so we cannot see exactly how the application assembled it.

Step 5: What was behind the login

Once inside, the domain exposed some developer profiles and their project files. In other words, the admin area of this machine held information about the company's own software developers and the projects they worked on.

He did not simply assume those people worked for the company. He searched for them on GitHub (where developers publish code) and LinkedIn (the professional network) and confirmed from those public sources that they were indeed employees. Only then did he consider the finding solid enough to report.

That step matters for a beginner: a name on a page proves nothing. Verifying it against independent public sources is what turns a guess into a finding.

Why the login was weak

What it implies is this: the text typed into the login form was placed into a database query without neutralising the single quote and the true-or-false expression. Because the quote closed the text early and 1=1 is always true, the check passed for any password.

What the impact was

The researcher logged in as admin and reached developer profiles and project files. The damage is limited to what that one machine held.

Two conditions had to hold for the finding to exist: the machine had to be discoverable through its certificate, and its login form had to be vulnerable.

How it should be fixed

A parameterised query keeps the user's text strictly as data and never lets it become part of the SQL command, so a quote typed into the password box stays a quote and nothing more.

Things you can try yourself

  1. Run the certificate search for other organisations: use the ssl:"organization name" query and open each result, looking for login pages that carry the organisation's branding. A good result is a machine that is not on the published scope but clearly belongs to the target.
  2. On every basic authentication page you find this way, try the same tautology in the password field. A good result is a successful login as admin.
  3. Compare the org: and ssl: results for the same organisation, to spot cloud-hosted machines that the org filter misses.
  4. After any bypass, look at what the session exposes, such as user profiles and project files, and check staff affiliation through public sources before reporting.

Only ever do this on systems you are authorised to test. The researcher was working inside a bug bounty program, which is a scheme where a company invites people to test its systems and pays for valid reports.

Timeline

He submitted the report to the company. It was triaged within 30 minutes, and he was rewarded in less than 3 hours.

Glossary

  • Authentication: the process of proving who you are, usually with a username and password.
  • Authentication bypass: getting past a login check without knowing the real credentials.
  • Basic authentication: the simplest login style, where the browser itself shows a small pop-up box asking for a username and password.
  • Bug bounty program: a scheme where a company invites researchers to test its systems and pays for valid reports of problems.
  • Certificate (TLS/SSL): a digital document that proves a server belongs to a particular organisation and enables the padlock in your browser; it usually carries the organisation's name.
  • Cloud provider: a company that rents out servers and services over the internet, such as Amazon cloud or Google Cloud.
  • Comment (in SQL): text the database ignores; in SQL it starts with --.
  • Duplicate: a report of a bug that someone else already reported first, which usually earns nothing.
  • IP address: the numeric address of a computer on the internet, like a postal address for a machine.
  • Parameterised query: a way of sending a database query where user input is kept strictly as data and can never become part of the command.
  • Reconnaissance (recon): gathering information about a target before attacking it, such as which machines it owns and what they run.
  • Scope: the list of systems a company has authorised researchers to test.
  • Shodan: a search engine that indexes internet-connected devices and the details they reveal, rather than web pages.
  • SQL: the language used to store and retrieve data in databases.
  • SQL injection (SQLi): putting SQL code into an input field so the application treats it as part of its own database question.
  • Tautology: a statement that is always true, such as 1=1, used here to make a login check pass.
  • Triaged: reviewed and confirmed as a valid issue by the receiving company.
  • URL encoding: representing characters in a web address in a safe form, for example a space as +.

More by Vijaysimha Reddy Bathini

View all

3 more disclosed reports, best first.

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.