Skip to content
SQL injection Write-up Beginner

Accessing the website directly through its IP address, a case of a poorly hidden sql injection

A subdomain appeared to be a static help page, but visiting the server's IP address directly revealed a login form vulnerable to SQL injection. A simple login bypass using a comment sequence logged the author into the admin panel.

Vuk Ivanovic Follow

Published on medium.com

{{media:0}}

Vuk Ivanovic, 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. 4 min read.

Context

This is a story about a SQL injection found on a bug bounty programme with a wide scope, the familiar *.website.com wildcard. The target was a subdomain that presented itself as a plain Help/About page. The interesting part is not the injection itself, which was a simple login bypass, but the route to it: the login form was not reachable through the subdomain at all, only by going straight to the IP address the subdomain resolved to.

The author frames the whole thing around two ideas: hiding in plain sight, and security through obscurity. Whether the exposure was deliberate obscurity or a coincidence, the report does not settle.

Setup

The work started with reconnaissance across the wildcard scope. The tools named in the report are massdns, amass and a bit of crt.sh, used to collect subdomains. No versions are given.

No accounts, roles or credentials were needed. The only precondition was that the subdomain resolved to an IP address that did not belong to a WAF or cloud provider, which is what made the direct-IP approach worth trying.

Finding it

After collecting subdomains, the author went through the ones whose names sounded interesting. One of them showed a simple Help/About me type of page. At first glance there was nothing there: no forms, no additional links, nothing to suggest it was anything but a static page.

Image for post
example of a static/boring web page, no bugs here? From the original on medium.com

That is the point where most people move on. The report argues against it. When a target looks empty, there are still headers to manipulate (Host, Referer, User-Agent, especially for blind XSS and SQL injection), and headers that are not part of requests by default, such as the X-Forwarded family. And there is one more thing worth a try, one that is easily forgotten or wrongly assumed to be a waste of time: the IP address.

Image for post
an example: where website.com resolves to ip address 10.2.3.2 From the original on medium.com

The reasoning about WAFs is explicit. If the target resolves to an IP address belonging to Akamai, Cloudflare, AWS or similar, the author tends to leave it alone, having had no luck figuring out the true IP behind a WAF. But when the IP does not resolve to any WAF or cloud provider, it may still be associated with vhosts of some kind, and you cannot tell unless you go directly to the IP address in question.

Exploitation

Step 1: resolve the subdomain and check the IP

Resolve the interesting subdomain and look at where the address belongs. If it sits behind a WAF or cloud provider, the report's advice is to move on. If it does not, continue.

Step 2: browse to the IP address directly

Entering the IP address in the browser loaded a different page, much different from the static Help/About page served through the subdomain.

The report does not reproduce the page itself beyond describing it as a login form.

Step 3: try a login bypass

The obvious thing to do when seeing a login form is:

Text
username: admin' #

pass: doesntmatter

The report does not explain the payload's mechanism, only that it worked. The password field is irrelevant. The report notes that there are other SQL injections for login bypass, and that in rare cases they work, even in 2020. This was one of those rare cases: the login succeeded and logged the author into the admin panel.

Root cause

The report does not analyse the server-side code, so the exact mistake is not shown. The password value was never meaningfully checked.

Why the existing defences did not stop it is also not stated. The report does not discuss why the form was reachable only via the IP address.

Impact

The author was logged into the admin panel through the bypass. The report does not describe what the panel allowed beyond that, so the wider impact is not established here. The conditions are worth stating plainly: the attack required the subdomain to resolve to an IP that was not behind a WAF or cloud provider, and it required the tester to browse to that IP directly rather than through the hostname.

Fix

Variants to test

  1. Resolve every in-scope subdomain and check the owning organisation of each IP. A positive result is an address that does not belong to a WAF or cloud provider, which makes a direct-IP visit worth trying.
  2. Browse to the bare IP address of each such host. A positive result is a page that differs from what the hostname serves, particularly a login form or an admin interface.
  3. On any login form found this way, try the bypass above. A positive result is a session that lands in the admin panel with an arbitrary password.
  4. On pages that look static and empty, vary Host, Referer and User-Agent, and add X-Forwarded family headers. A positive result is a different response suggesting the header is used.
  5. When a subdomain looks uninteresting, remember the basics and port scan the resolved IP.

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. 9 min read.

What happened, in plain words

A security researcher was taking part in a bug bounty programme. A bug bounty programme is a scheme where an organisation invites people to test its systems and report security problems, usually paying for good findings. The programme in this story had a very wide scope: everything under *.website.com was fair game, meaning any subdomain of the main site. A subdomain is a name like help.website.com that sits in front of the main domain.

The researcher collected as many subdomains as possible, then looked through the ones whose names sounded interesting. One of them showed a simple Help/About page. It had no forms, no links, nothing to click. Most people would move on. The researcher did not, and instead tried something basic: visiting the IP address that the subdomain points to.

An IP address is the numeric address of a computer on the internet, something like [redacted]. When you type a website name into your browser, a lookup service called DNS translates that name into an IP address, and the browser connects to that address. Normally you never see the number. But you can type the number into the browser yourself, and the server will answer. Sometimes it answers with something completely different from what the name serves.

That is what happened here. The IP address loaded a login form that the subdomain never showed. The researcher tried a classic trick on that form, a login bypass using SQL injection, and it worked: the form let them into the admin panel without a real password.

SQL injection is a whole category of bug. It happens when a website builds a database query by gluing together text that includes something the user typed, without separating the two. If the user types characters that the database treats as instructions rather than as data, the query changes meaning. A login bypass is the simplest version: you make the query accept you without checking your password.

The author frames the story around two phrases. "Hiding in plain sight" means the thing was there all along, just not where you would look. "Security through obscurity" means relying on something being hard to find as your protection. Whether the login form was deliberately hidden or just accidentally reachable, the report does not say.

Setup

Before any testing, the researcher did reconnaissance. Reconnaissance (recon) means gathering information about a target: which machines exist, which names point to them, which services they run. It is the map-making phase, and it happens before any attempt to break anything.

The tools named in the report are massdns, amass and a bit of crt.sh. All three are used to collect subdomains:

  • massdns is a fast tool for sending many DNS lookups at once. A DNS lookup is the question "what IP address does this name point to?".
  • amass is a tool that maps out an organisation's internet-facing names, pulling from many sources.
  • crt.sh is a public website that lists certificates issued for domain names. Because certificates are issued per name, the list leaks names that the organisation may not have advertised.

The report gives no versions for any of these tools.

No accounts, roles or credentials were needed to start. The only precondition was that the interesting subdomain resolved to an IP address that did not belong to a WAF or a cloud provider. A WAF (web application firewall) is a filter that sits in front of a website and inspects incoming requests, blocking ones that look malicious. Cloud providers such as AWS rent out servers and often put their own protective layers in front of them. If the address belongs to one of those, going straight to the IP usually just hits the filter. If it does not, the direct visit is worth trying.

Finding it

After collecting subdomains, the researcher went through the ones whose names sounded interesting. One of them showed a simple Help/About me type of page. At first glance there was nothing there: no forms, no additional links, nothing to suggest it was anything but a static page. A static page is one that is just a fixed file sent to the browser, with no login, no database, no interaction.

Image for post
example of a static/boring web page, no bugs here? From the original on medium.com

That is the point where most people move on. The report argues against it. When a target looks empty, there are still things to try:

  1. Headers you can change. Every request your browser sends carries headers, which are small labelled lines of extra information. Host says which site you want, Referer says which page you came from, User-Agent says which browser you use. If the server uses any of these to build a query, changing them can reach the bug. The report mentions this especially for blind XSS and SQL injection. Blind XSS is a cross-site scripting bug where the malicious input is stored and later runs in someone else's browser, such as an administrator's, so you never see the result directly.
  2. Headers that are not normally there. The X-Forwarded family of headers is used by proxies and load balancers to pass along information about the original request. Adding them by hand can make the server behave differently.
  3. The IP address. This is the one the report stresses, because it is easily forgotten or wrongly assumed to be a waste of time.
Image for post
an example: where website.com resolves to ip address 10.2.3.2 From the original on medium.com

The reasoning about WAFs is explicit. If the target resolves to an IP address belonging to Akamai, Cloudflare, AWS or similar, the author tends to leave it alone, having had no luck figuring out the true IP behind a WAF. But when the IP does not resolve to any WAF or cloud provider, it may still be associated with vhosts of some kind, and you cannot tell unless you go directly to the IP address in question. A vhost (virtual host) is a way for one server to host several websites on the same address, choosing which one to serve based on the name you asked for. That is exactly why a bare IP can show something different from the name.

Exploitation

Step 1: resolve the subdomain and check the IP

Resolve the interesting subdomain and look at where the address belongs. Resolving means turning the name into an IP address, which you can do with a lookup tool or an online service. Then check who owns that address. If it sits behind a WAF or cloud provider, the report's advice is to move on. If it does not, continue.

Step 2: browse to the IP address directly

Entering the IP address in the browser loaded a different page, much different from the static Help/About page served through the subdomain.

The report does not reproduce the page itself beyond describing it as a login form. A login form is the pair of boxes where you type a username and a password.

Step 3: try a login bypass

The obvious thing to do when seeing a login form is:

Text
username: admin' #

pass: doesntmatter

Line by line, in plain words:

  • username: admin' # is what goes into the username box. admin is the account name being targeted. The single quote ' is the important character: in SQL, text values are wrapped in single quotes, so typing one can end the text early and let whatever follows be read as part of the query. The # starts a comment in SQL, so everything after it is ignored.
  • pass: doesntmatter is what goes into the password box. The value is irrelevant, and the word chosen makes that clear.

The report does not explain why the payload worked, only that it did. The database then finds the admin user and the password is never compared.

The report notes that there are other SQL injections for login bypass, and that in rare cases they work, even in 2020. This was one of those rare cases: the login succeeded and logged the author into the admin panel. The admin panel is the private management area of the site, normally only reachable with an administrator's credentials.

Root cause

The report does not analyse the server-side code, so the exact mistake is not shown. Parameterisation (or a prepared statement) means sending the query and the values separately, so the database always treats the values as data and never as instructions. Without it, the quote broke out of the text and the comment removed the remainder of the condition. The password value was never meaningfully checked.

Why the existing defences did not stop it is also not stated. The report does not discuss why the form was reachable only via the IP address.

Impact

The author was logged into the admin panel through the bypass. The conditions are worth stating plainly: the attack required the subdomain to resolve to an IP that was not behind a WAF or cloud provider, and it required the tester to browse to that IP directly rather than through the hostname.

Fix

Variants to test

  1. Resolve every in-scope subdomain and check the owning organisation of each IP. A positive result is an address that does not belong to a WAF or cloud provider, which makes a direct-IP visit worth trying.
  2. Browse to the bare IP address of each such host. A positive result is a page that differs from what the hostname serves, particularly a login form or an admin interface.
  3. On any login form found this way, try the bypass above. A positive result is a session that lands in the admin panel with an arbitrary password.
  4. On pages that look static and empty, vary Host, Referer and User-Agent, and add X-Forwarded family headers. A positive result is a different response suggesting the header is used.
  5. When a subdomain looks uninteresting, remember the basics and port scan the resolved IP.

Glossary

  • Bug bounty programme: a scheme where an organisation invites outsiders to test its systems and report security problems, often paying for good findings.
  • Scope: the set of systems a tester is allowed to attack.
  • Wildcard scope: a rule like *.website.com that covers every subdomain of a domain.
  • Subdomain: a name in front of a domain, such as help.website.com.
  • DNS: the internet's name-to-address lookup service.
  • Resolve: turn a domain name into an IP address.
  • IP address: the numeric address of a machine on the internet.
  • Reconnaissance (recon): gathering information about a target before attacking it.
  • massdns: a fast tool for sending many DNS lookups at once.
  • amass: a tool that maps out an organisation's internet-facing names from many sources.
  • crt.sh: a public site listing certificates issued for domain names, useful for finding names.
  • WAF (web application firewall): a filter in front of a website that inspects requests and blocks suspicious ones.
  • Cloud provider: a company that rents out servers and often adds its own protective layers, such as AWS.
  • Vhost (virtual host): one server hosting several websites on the same address, choosing which to serve based on the requested name.
  • Static page: a fixed file sent to the browser, with no login, database or interaction.
  • Header: a small labelled line of extra information sent with every web request or response.
  • Host header: the header that says which site the browser wants.
  • Referer header: the header that says which page the request came from.
  • User-Agent header: the header that says which browser and system made the request.
  • X-Forwarded family: headers used by proxies and load balancers to pass along information about the original request.
  • Blind XSS: a cross-site scripting bug where stored input later runs in someone else's browser, so the attacker never sees the result directly.
  • SQL injection: a bug where user input changes the meaning of a database query.
  • Login bypass: a SQL injection that lets you log in without knowing the password.
  • SQL: the language used to talk to relational databases.
  • Comment (in SQL): a marker such as # that makes the database ignore the rest of the line.
  • Parameterisation / prepared statement: sending a query and its values separately so the values can never be read as instructions.
  • Admin panel: the private management area of a website, normally reachable only with administrator credentials.
  • Security through obscurity: relying on something being hard to find as your protection.
  • Control: a measure that actually stops an attack, such as a filter or a permission check.
  • Port scan: asking a machine which numbered doors (ports) are open and answering.

More by Vuk Ivanovic

View all

13 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.