How I Found Multiple Bugs On FaceBook In 1 Month And a Part For My Methodology & Tools
The author found multiple vulnerabilities on Facebook-owned assets, including SQL injection, authentication bypass, server-side template injection leading to remote code execution, and privilege escalation. An attacker could exploit these to gain unauthorised access, execute commands, and escalate privileges.
Published on orwaatyat.medium.com
Iam Orwa [https://twitter.com/GodfatherOrwa]
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.
Context
This is a write-up about hunting on Facebook's bug bounty program, carried out by Orwa Atyat (@GodfatherOrwa) together with HackerX007. The author is explicit that the piece is about how the bugs were found rather than what was found, and that the goal is for the reader to learn the process. The findings described are:
- Server-Side Template Injection leading to RCE (Critical)
- SQL Injection, two instances (Critical)
- Authentication Bypass (Critical)
- Privilege Escalation (Critical)
- Multiple Reflected XSS (Medium)
Some of these were accepted and some were closed as duplicates. The author notes that the second SQL injection and one of the XSS findings were duplicates because the security team already knew about them and were working on a fix, while one XSS was accepted.
Setup
The author lists the tooling used across the whole engagement.
Wordlists and subdomain enumeration
- FFUF or Dirsearch, both liked equally.
- The "Random Robbie" wordlist, at
https://github.com/random-robbie/bruteforce-lists. - Amass for subdomains, plus checking GitHub for subdomains and fuzzing for subdomains with a wordlist. The Amass commands given are:
amass enum -passive -norecursive -noalts -df list-domains.txt -o subs.txt
for a list of domains, and
amass enum -passive -norecursive -noalts -d domain-o subs.txt
for a single domain (the second command is reproduced as written in the report).
Probing live hosts
Httpx, httprobe and Nmap. The httpx step:
cat subs.txt | httpx -o live-subs.txt
and the httprobe step, which probes a set of non-standard ports:
cat sub.txt | httprobe -p http:81 -p http:3000 -p https:3000 -p http:3001 -p https:3001 -p http:8000 -p http:8080 -p https:8443 -p https:10000 -p http:9000 -p https:9443 -c 50 | tee live-subs2.txt
Other tools
- Wappalyzer for technology fingerprinting.
- Burp Pro with the following extensions: Collaborator Everywhere, XSS Validator, Wsdler, .NET Beautifier, Bypass WAF, J2EEScan, Param Miner, Wayback Machine, JS Link Finder, Upload Scanner, Nucleus Burp Extension, Software Vulnerability Scanner, Active Scan++.
- Acunetix, or reNgine as a free alternative.
Finding it
First domain: SQL injection, authentication bypass and XSS
Recon started by dorking GitHub for Facebook-related domains. The dorks tried were:
org:facebookresearch ftp
org:facebookresearch Ldap
org:facebookresearch https://
and, after roughly 30 minutes, the one that paid off:
org:facebookresearch language:python .php
This surfaced an endpoint of the form:
domain/login/_ajax/verify-2fa.php
Visiting it revealed an employee panel owned by Instagram. Testing the username parameter with the query 1' returned a MySQL error, which suggested the parameter was injectable.
Second target: SSTI on an exposed port
The author moved to Shodan to find IPs belonging to Facebook. Two dorks are given. To look for domains or IPs belonging to the program:
Org:"FaceBook Inc."
with the note that the 200 filter is not needed in this case because live IPs are not required. To look for subdomains or IPs on the domain:
Ssl.cert.subject.CN:"facebook.com" 200
An interesting IP was found with port 10000 listed, but that port was not working. An Nmap service scan showed port 8443 open:
Nmap -sV ip
The host turned out to be an AWS host owned by Facebook. The author collected many IPs of this kind and queued them in Acunetix to scan in the background.
Third target: privilege escalation via a management panel
crt.sh was used to look at about five interesting domains:
https://crt.sh/?q=Facebook+Inc.
Rather than the normal subdomain-gathering route, the author fuzzed for subdomains with a large custom wordlist, then filtered to live hosts with the httprobe command shown above. This surfaced a domain running on port 10000, which presented a panel for managing servers and other resources.
Exploitation
Step 1: Confirming and exploiting the SQL injection
The request was intercepted in Burp and saved to a text file, then run through sqlmap against the username parameter:
sqlmap -r request.txt -p username --dbms="MySQL" --force-ssl --level 5 --risk 3 --dbs --hostname
The report states this succeeded. After that, the full host was spidered, PHP endpoints were fuzzed with a PHP wordlist, and an active scan was run in Burp against all POST requests, with the maximum insertion points per base request set to 10.
This produced a second SQL injection and two XSS payloads:
"><img src=x onerror=alert(1)>
The second SQL injection was closed as a duplicate, as was one of the XSS findings; the other XSS was accepted.
Step 2: The authentication bypass
HackerX007 found this one through manual testing. Visiting domain/location/?5 redirects to the login page, but in Burp the redirect response had a very large Content-Length of 6443. Inspecting that 302 response showed the panel content was present in the body without any authentication. After some work with Burp match and replace, the authentication could be bypassed and actions could be taken. The author initially assumed it was only a front-end bypass, but found that real actions were possible, such as enabling and disabling a bucket.
The reproduction steps, as given:
- In Burp match and replace, add:
type: response header
match : HTTP/1.1 302 Found
replace: HTTP/1.1 200 ok
and
type: response header
match : Location: ../login/?redirect=//location/?5
replace:
- Then visit
domian//location/?5(spelling as in the report). - The panel is reached.
- When finished, the user can log out.
This authentication bypass was accepted.
Step 3: SSTI to RCE
Acunetix flagged the collected IPs as vulnerable to SSTI, with the payload placed in a parameter called mode that calls debug in Python. The author confirmed it with the standard probe {{5*5}}, which appeared as 25 in the source. The faster route is tplmap, installed with:
git clone https://github.com/epinna/tplmap.git
The confirmation command:
./tplmap.py -u "https://ip:8443/consent?assignmentId=debugKUymD&hitId=debugiwTmj&mode=debug*"
which reported:
GET parameter: modeEngine: Jinja2Injection: {{*}}Context: textOS: posix-linuxTechnique: render
The important part was that Python code evaluation was possible, which means command execution on the shell, bind and reverse shells, and file write and read, though the report notes file operations are not possible in all cases. To get a shell:
./tplmap.py -u "https://ip:8443/consent?assignmentId=debugKUymD&hitId=debugiwTmj&mode=debug*" --os-shell
Only id was checked and a ping back to Burp Collaborator was made. This SSTI was accepted.
Step 4: Privilege escalation
The management panel on port 10000 was fingerprinted with Wappalyzer, then dirsearch was run against it. Several endpoints were accessible without any login, which the author notes was worth reporting on its own, but none of them granted privileges such as edit, delete or add. Default credentials were tried without success, and sign-up was not possible because registration requires an admin login.
While checking endpoints, the author found a server info page that disclosed the full name of the admin who created the panel. That was enough to locate the employee's GitHub repository within about five minutes. Dorking that repository for password-related strings was attempted with:
passwordpasswd pwdpasspwlogin
This surfaced a GitHub leak containing an internal host, a user and a password, in the form:
$host = ************
$User = ************
$pwd = ************
The internal host was scanned for open ports and none were found. Logging into the panel with the leaked username and password succeeded, giving full privileges: adding users, deleting users and other administrative actions. A stored XSS was also found in this panel.
Root cause
The username parameter of the 2FA verification endpoint returned a MySQL error when tested with 1'. The 302 redirect to the login page had a large body containing the panel, and Burp match and replace rules changed the status to 200 and removed the Location header. The SSTI was in a mode parameter that calls debug in Python; tplmap identified the engine as Jinja2 and Python evaluation was possible. A server info page disclosed the admin's full name, a GitHub repository held a leaked host, user and password, and the panel accepted those credentials with full privileges. The report does not describe the server-side fixes.
Impact
The SQL injection was confirmed on an employee-facing 2FA endpoint, and sqlmap was used to list databases. The authentication bypass let an unauthenticated user take actions in a panel, including enabling and disabling a bucket. The SSTI gave command execution on the host, with bind and reverse shells and, in some cases, file read and write. The privilege escalation gave full control of a server management panel, including user management, and a stored XSS in that panel. The report does not state which of these were rewarded or how they were remediated.
Fix
Based on the findings, the SQL injection needs parameterised queries and error suppression, the redirect should not include panel content in the body, the debug mode parameter should not be reachable in production and template rendering should not evaluate user input, and credentials should not be committed to public repositories.
Variants to test
- GitHub dorking for internal endpoints. Try organisation-scoped dorks with language and extension filters, as above. A positive result is a URL that resolves to a login or admin panel.
- Error-based SQL probing. Send a single quote in each parameter and look for database error text. A positive result is a MySQL or other DB error naming the parameter.
- Redirect body inspection. For any 302 to a login page, check the
Content-Lengthand body in Burp. A positive result is panel content in the redirect body. - Match and replace bypass. Rewrite
302 Foundto200 okand blank theLocationheader. A positive result is the panel rendering and actions succeeding. - SSTI probing. Send
{{5*5}}in parameters that look like debug or mode switches. A positive result is25in the response. - tplmap confirmation and shell. Run tplmap against the parameter, then
--os-shell. A positive result is engine identification and command output. - Shodan for exposed services. Use
Org:"FaceBook Inc."andSsl.cert.subject.CN:"facebook.com" 200style dorks, then Nmap the hosts. A positive result is an unexpected open port such as 8443. - Panel information disclosure. Look for server info pages that reveal admin names. A positive result is a name that leads to a public repository.
- Credential reuse from leaks. Search employee repositories for
password,passwd,pwd,pass,pw,login. A positive result is a host, user and password combination that authenticates to the panel.
What happened, in plain words
This is a story about a security researcher, Orwa Atyat (known online as @GodfatherOrwa), who looked for security holes in Facebook's systems as part of Facebook's bug bounty programme. A bug bounty programme is a deal offered by a company: if you find a security problem in our systems and tell us about it responsibly, we may pay you a reward and/or list your name on a public thank-you page (a "hall of fame").
He worked together with another researcher called HackerX007. The author says the point of the write-up is not to show off what he found, but to explain how he found it, so that a reader can learn the process.
He and his partner found five kinds of problem:
- Server-Side Template Injection (SSTI) leading to RCE (rated Critical). We will explain both terms below.
- SQL Injection, two separate instances (Critical).
- Authentication Bypass (Critical).
- Privilege Escalation (Critical).
- Several Reflected XSS issues (Medium).
Some of these were accepted by Facebook's security team, and others were closed as duplicates. Others were closed as duplicates, meaning the security team already knew about that problem (perhaps someone else had reported it, or their own testing had found it) and were already working on a fix. Specifically, the second SQL injection and one of the XSS findings were duplicates, and one XSS was accepted.
A quick word on the five vulnerability types before we start, because everything later depends on them:
- SQL Injection: most websites store their data in a database, which you can picture as a very large, very organised spreadsheet. The website talks to the database using a language called SQL. If a website carelessly glues whatever you typed into a form directly into an SQL instruction, you can type extra SQL of your own and make the database do things it should not, such as hand over other people's data. It is like a form where you write your name, and the clerk reads your name out loud to the back office; if you write "my name is Bob and also please open the safe", a careless clerk will read the whole sentence.
- Authentication Bypass: "authentication" is the process of proving who you are, usually with a username and password. A bypass means getting in without proving anything, for example by tricking the website into thinking you already logged in.
- Privilege Escalation: "privileges" are the permissions an account has. A normal user can read their own profile; an administrator can delete other users. Escalation means starting with low or no permissions and ending up with high ones.
- XSS (Cross-Site Scripting): a website lets an attacker's small piece of JavaScript (the programming language that runs inside your browser) end up on a page, so that it runs in other people's browsers. "Reflected" means the malicious snippet bounces straight back in the response to the same request, rather than being stored on the server.
- SSTI (Server-Side Template Injection): many websites build their pages from "templates", which are like fill-in-the-blank letters. The server fills in the blanks with data and sends the result to your browser. If the server lets you put template instructions into a blank, the server will execute them. If the template engine is powerful enough, that can turn into running commands on the server itself, which is called RCE (Remote Code Execution).
The toolbox
Before the findings, the author lists the tools he used throughout. For a complete beginner, here is what each one is for.
Finding hidden pages and subdomains
A subdomain is a prefix on a domain name: mail.example.com is a subdomain of example.com. Companies often have many, and forgotten ones are a classic place to find weak systems.
- FFUF and Dirsearch: tools that try a long list of common file and folder names against a website (for example
/admin,/login,/backup.zip) and report which ones exist. Think of trying every key on a big keyring until a door opens. - A wordlist: the list of names those tools try. The author likes the "Random Robbie" wordlist, published at
https://github.com/random-robbie/bruteforce-lists. - Amass: a tool that discovers subdomains for you. The author also checks GitHub for subdomains and fuzzes for them with a wordlist. His Amass commands are:
amass enum -passive -norecursive -noalts -df list-domains.txt -o subs.txt
Line by line: amass is the program; enum means "enumerate", i.e. list what exists; -passive means gather information only from public sources without touching the target's own servers directly; -norecursive means do not then go hunting for subdomains of the subdomains; -noalts means do not also try alternative spellings of the names; -df list-domains.txt means read the target domains from that text file; -o subs.txt means write the results into subs.txt.
amass enum -passive -norecursive -noalts -d domain-o subs.txt
This is the single-domain version, reproduced exactly as it appears in the report: -d domain names one domain to look at, and -o subs.txt writes the output to the file. (The text runs domain and -o together as written.)
Checking which hosts are actually alive
- httpx and httprobe: take a list of hostnames and check which ones actually answer over HTTP or HTTPS. Many subdomains in a list are dead; these tools filter to the live ones.
- Nmap: a scanner that probes a host and reports which network ports are open and which services are listening on them. A port is a numbered door on a computer; web traffic normally uses 80 (HTTP) and 443 (HTTPS), but services can be put on any number.
The httpx step:
cat subs.txt | httpx -o live-subs.txt
cat subs.txt prints the contents of the subdomain list; the vertical bar | means "pass that output as input to the next program"; httpx checks each name; -o live-subs.txt saves the live ones to a file.
The httprobe step is longer because it also checks unusual ports:
cat sub.txt | httprobe -p http:81 -p http:3000 -p https:3000 -p http:3001 -p https:3001 -p http:8000 -p http:8080 -p https:8443 -p https:10000 -p http:9000 -p https:9443 -c 50 | tee live-subs2.txt
cat sub.txt prints the list; httprobe checks each host; each -p http:PORT or -p https:PORT adds one more port to try (81, 3000, 3001, 8000, 8080, 8443, 10000, 9000, 9443), because companies often run internal tools on these non-standard numbers; -c 50 means run 50 checks at a time; tee live-subs2.txt both shows the results on screen and saves them to the file. The unusual ports matter later: one of the findings lives on port 10000 and another on 8443.
Identifying what software a site runs
- Wappalyzer: a browser extension that looks at a website and guesses which technologies it uses (which web server, which programming language, which framework). Knowing the software helps you guess which weaknesses to test for.
Intercepting and replaying web traffic
- Burp Suite Pro: the central tool of the whole story. Your browser normally talks to a website directly. Burp sits in the middle like a postal worker who opens every letter, lets you read and rewrite it, and then sends it on. That lets you change a request before it reaches the server, or change the server's reply before your browser sees it. "Pro" is the paid edition.
- Burp extensions are add-ons that automate common checks. The author lists: Collaborator Everywhere, XSS Validator, Wsdler, .NET Beautifier, Bypass WAF, J2EEScan, Param Miner, Wayback Machine, JS Link Finder, Upload Scanner, Nucleus Burp Extension, Software Vulnerability Scanner, Active Scan++.
Automated scanners
- Acunetix: a commercial scanner that crawls a website and automatically tests for many known classes of vulnerability. The author also mentions reNgine as a free alternative.
Finding 1: SQL injection, authentication bypass and XSS on the first domain
Looking for targets on GitHub
The hunt started on GitHub, the website where programmers store and share code. Companies publish code there under an "organisation" account, and sometimes that code, or the notes around it, mentions internal servers. Searching GitHub with special filters is called dorking. The author tried:
org:facebookresearch ftp
org:facebookresearch Ldap
org:facebookresearch https://
Each line is a search: org:facebookresearch restricts results to the facebookresearch organisation, and the extra word (ftp, Ldap, https://) looks for pages mentioning those things. FTP and LDAP are older protocols for file transfer and directory services; mentions of them can point at internal infrastructure.
After about 30 minutes, the search that worked was:
org:facebookresearch language:python .php
language:python limits to repositories GitHub classifies as Python, and .php looks for text mentioning PHP files. That combination surfaced an endpoint of the form:
domain/login/_ajax/verify-2fa.php
An endpoint is a specific address on a server that does one job. This one is a login helper that verifies a 2FA code. 2FA means two-factor authentication: after your password, the site asks for a second proof, usually a short code from your phone. The .php ending tells you the page is written in the PHP programming language.
Visiting it showed an employee panel owned by Instagram. A panel here means an internal web page meant for staff, not the public.
Testing for SQL injection
The author typed a single quote, 1', into the username field. A parameter is a named value sent to a server, like username=orwa. The single quote is the classic probe because in SQL, text values are wrapped in quotes; an extra quote can break the instruction and make the database complain. The site returned a MySQL error. MySQL is a popular database program. An error message like that is a strong hint that your text went straight into a database instruction, which is exactly the SQL injection condition.
To work on the request properly, he intercepted it in Burp and saved a copy to a text file. Then he ran sqlmap, a tool that automates SQL injection testing, against the saved request:
sqlmap -r request.txt -p username --dbms="MySQL" --force-ssl --level 5 --risk 3 --dbs --hostname
Line by line: sqlmap is the program; -r request.txt tells it to read a saved HTTP request from that file, so it repeats exactly what the browser sent; -p username says test only the username parameter; --dbms="MySQL" says the database is MySQL, so it can pick the right tricks; --force-ssl makes it use HTTPS (the encrypted version of web traffic); --level 5 and --risk 3 are the highest thoroughness settings, meaning it will try more and more aggressive tests; --dbs asks it to list the databases on the server; --hostname asks for the database server's hostname. The report says this succeeded.
Widening the search on the same host
With one injection confirmed, he spidered the host, meaning he let a tool crawl the site and collect every link and page it could reach, then fuzzed for PHP pages using a PHP-specific wordlist, and ran Burp's active scan against every POST request. A POST request is the kind a browser sends when you submit a form, carrying your data in the body rather than in the address. He set the maximum insertion points per base request to 10, which controls how many places in each request the scanner is allowed to inject test payloads into.
This turned up a second SQL injection and two XSS payloads:
"><img src=x onerror=alert(1)>
This is a small piece of HTML, the language web pages are written in. "> first closes whatever attribute the site had put the value into, so the rest is treated as new HTML. <img src=x ...> asks the browser to display an image from the address x, which does not exist. onerror=alert(1) is the trick: when the image fails to load, the browser runs that little bit of JavaScript, and alert(1) makes a pop-up box appear with the number 1. A pop-up is harmless in itself; it is the standard proof that you can run your own JavaScript on someone else's page, which is what XSS means.
The second SQL injection was closed as a duplicate, as was one of the XSS findings; the other XSS was accepted.
The authentication bypass
HackerX007 found this one by hand. Visiting domain/location/?5 redirects to the login page. A redirect is the server telling your browser "not here, go there instead", and it does so with a special status code, 302. In Burp, though, the redirect response had a very large Content-Length of 6443. Content-Length is a header, a small label attached to every web response, saying how many bytes of body follow. A redirect normally has almost no body, so 6443 bytes was suspicious.
Looking inside that 302 response showed the panel's content was sitting in the body, with no authentication required to receive it. The server was, in effect, saying "go to the login page" while also handing over the page you were not allowed to see. After some work with Burp's match and replace feature, which automatically rewrites parts of requests and responses as they pass through, the login could be skipped and actions could be taken. The author first assumed it was only a front-end bypass, meaning only the browser was fooled and the server would still refuse real actions. He then found that real actions worked, such as enabling and disabling a bucket. A bucket here is a storage container in a cloud service.
The reproduction steps, as given:
- In Burp match and replace, add:
type: response header
match : HTTP/1.1 302 Found
replace: HTTP/1.1 200 ok
This rule watches the headers of responses coming back from the server. HTTP/1.1 302 Found is the status line saying "redirect". It rewrites it to HTTP/1.1 200 ok, which means "here is the page you asked for, all fine". Your browser then treats the reply as the actual page instead of a redirect.
And a second rule:
type: response header
match : Location: ../login/?redirect=//location/?5
replace:
Location is the header that tells the browser where the redirect points, here the login page. The replace: line is empty, so the header is deleted. With no instruction to go to the login page, and a 200 status, the browser simply displays the body it was given, which is the panel.
- Then visit
domian//location/?5(spelling as in the report). - The panel is reached.
- When finished, the user can log out.
This authentication bypass was accepted.
Finding 2: SSTI leading to RCE on an exposed port
Finding Facebook-owned machines with Shodan
Shodan is a search engine for internet-connected devices and servers, rather than for web pages. You can search it for machines belonging to a particular organisation. The author gives two searches. To look for domains or IPs belonging to the programme:
Org:"FaceBook Inc."
Org: filters by the organisation the IP address is registered to. The author notes the 200 filter is not needed here, because he does not need the machines to be serving a working website. To look for subdomains or IPs on the domain:
Ssl.cert.subject.CN:"facebook.com" 200
This searches for servers whose TLS certificate names facebook.com. A TLS certificate is the digital ID a website presents so your browser can confirm it is really talking to the right place; the CN (common name) field inside it holds the domain name. The 200 at the end asks Shodan to return only hosts that answered with HTTP status 200, meaning a working page.
An interesting IP was found with port 10000 listed, but that port was not working. An Nmap service scan showed port 8443 open:
Nmap -sV ip
Nmap is the scanner; -sV means also detect the version of the service listening on each open port, not just whether the port is open; ip is the address to scan. The host turned out to be an AWS host owned by Facebook. AWS (Amazon Web Services) is a large cloud provider where companies rent servers.
The author collected many IPs of this kind and queued them in Acunetix to scan in the background, so the scanner could work while he did other things.
Confirming the template injection
Acunetix flagged the collected IPs as vulnerable to SSTI, with the payload placed in a parameter called mode that calls debug in Python. In plain terms: the page had a setting called mode, and setting it to debug made the server run some Python code. Python is a programming language. The author confirmed the problem with the standard probe {{5*5}}. In many template engines, anything inside double curly braces is treated as an instruction to calculate, not as text. If the page shows 25, the server did the multiplication for you, which proves your input is being executed as code.
The faster route is tplmap, a tool that automates template injection testing, in the same spirit as sqlmap. It is installed with:
git clone https://github.com/epinna/tplmap.git
git is the version-control program programmers use to download and track code; clone means copy the whole project from that address onto your machine.
The confirmation command:
./tplmap.py -u "https://ip:8443/consent?assignmentId=debugKUymD&hitId=debugiwTmj&mode=debug*"
./tplmap.py runs the downloaded script; -u gives the URL to test. The URL points at port 8443 on the host, to a page called consent, and carries three parameters: assignmentId, hitId and mode. The * at the end of mode=debug* marks the spot where tplmap should inject its test payloads.
It reported:
GET parameter: modeEngine: Jinja2Injection: {{*}}Context: textOS: posix-linuxTechnique: render
Reading this: the vulnerable spot is the mode parameter of a GET request (a GET request is the ordinary kind your browser sends when you open a page, with data in the address); the template engine is Jinja2, a popular Python template system; the injection marker is {{*}}; the context is text; the operating system is a Linux-style system (posix-linux); and the technique used is rendering.
The important part was that Python code evaluation was possible. That means command execution on the shell, bind and reverse shells, and file write and read, though the report notes file operations are not possible in all cases. A shell is a way to type commands directly to a computer's operating system. A bind shell makes the victim machine listen for the attacker to connect in; a reverse shell makes the victim connect out to the attacker, which often slips past firewalls because outgoing connections are usually allowed.
To get a shell:
./tplmap.py -u "https://ip:8443/consent?assignmentId=debugKUymD&hitId=debugiwTmj&mode=debug*" --os-shell
Same command as before, with --os-shell added, which asks tplmap to turn the injection into an interactive command shell on the server. Only id was checked, a command that prints which user the server is running as, and a ping back to Burp Collaborator was made. Burp Collaborator is a service that gives you a unique address you control, so that when the target contacts it, you know your command really ran. This SSTI was accepted.
Finding 3: Privilege escalation through a management panel
Finding the panel
The author used crt.sh, a public search engine for TLS certificates. Because every certificate records the names it was issued for, crt.sh is a good way to discover subdomains. He looked at about five interesting domains:
https://crt.sh/?q=Facebook+Inc.
?q= is the search query, here the organisation name with + standing for a space.
Rather than the normal subdomain-gathering route, he fuzzed for subdomains with a large custom wordlist, then filtered to live hosts with the httprobe command shown earlier. This surfaced a domain running on port 10000, which presented a panel for managing servers and other resources.
Probing the panel
He fingerprinted the panel with Wappalyzer, then ran dirsearch against it. Several endpoints were accessible without any login. The author notes this was worth reporting on its own, but none of them granted privileges such as edit, delete or add, so it was not enough. Default credentials were tried without success. Default credentials are the factory username and password a product ships with, like admin/admin, which careless installations never change. Sign-up was not possible because registration requires an admin login.
While checking endpoints, he found a server info page that disclosed the full name of the admin who created the panel. That was enough to locate the employee's GitHub repository within about five minutes. This is a chain of small leaks: a name is not a password, but a name leads to a public profile, which leads to code, which sometimes contains secrets.
Dorking that repository for password-related strings was attempted with:
passwordpasswd pwdpasspwlogin
This is a list of search words run together as written in the report: password, passwd, pwd, pass, pw, login. The idea is that people who save credentials in code often label them with one of these words.
This surfaced a GitHub leak containing an internal host, a user and a password, in the form:
$host = ************
$User = ************
$pwd = ************
These look like lines of a configuration file or script, where $host, $User and $pwd are variables holding the server address, the username and the password. The asterisks stand in for the real values, which are not reproduced here.
The internal host was scanned for open ports and none were found. Logging into the panel with the leaked username and password succeeded, giving full privileges: adding users, deleting users and other administrative actions. A stored XSS was also found in this panel. Stored XSS means the malicious snippet is saved on the server and served to every visitor, rather than bouncing back only to the person who sent it.
Why these bugs existed
The username parameter of the 2FA verification endpoint returned a MySQL error when tested with 1'. Unsanitised means the site used what was typed without checking or neutralising it first.
The 302 redirect to the login page had a large body containing the panel, and Burp match and replace rules changed the status to 200 and removed the Location header.
The SSTI was in a mode parameter that calls debug in Python; tplmap identified the engine as Jinja2 and Python evaluation was possible.
A server info page disclosed the admin's full name, a GitHub repository held a leaked host, user and password, and the panel accepted those credentials with full privileges.
The report does not describe the server-side fixes.
What the impact was
The SQL injection was confirmed on an employee-facing 2FA endpoint, and sqlmap was used to list databases. The authentication bypass let an unauthenticated user take actions in a panel, including enabling and disabling a bucket. The SSTI gave command execution on the host, with bind and reverse shells and, in some cases, file read and write. The privilege escalation gave full control of a server management panel, including user management, and a stored XSS in that panel. The report does not state which of these were rewarded or how they were remediated.
How they should be fixed
Based on the findings, the SQL injection needs parameterised queries and error suppression. Parameterised queries mean the database is given your data separately from the instruction, so it can never be read as code. Error suppression means not showing raw database errors to visitors. The redirect should not include panel content in the body. The debug mode parameter should not be reachable in production, and template rendering should not evaluate user input. Credentials should not be committed to public repositories.
Things worth trying yourself
- GitHub dorking for internal endpoints. Try organisation-scoped searches with language and extension filters, as above. A positive result is a URL that resolves to a login or admin panel.
- Error-based SQL probing. Send a single quote in each parameter and look for database error text. A positive result is a MySQL or other database error naming the parameter.
- Redirect body inspection. For any 302 to a login page, check the
Content-Lengthand body in Burp. A positive result is panel content in the redirect body. - Match and replace bypass. Rewrite
302 Foundto200 okand blank theLocationheader. A positive result is the panel rendering and actions succeeding. - SSTI probing. Send
{{5*5}}in parameters that look like debug or mode switches. A positive result is25in the response. - tplmap confirmation and shell. Run tplmap against the parameter, then
--os-shell. A positive result is engine identification and command output. - Shodan for exposed services. Use
Org:"FaceBook Inc."andSsl.cert.subject.CN:"facebook.com" 200style searches, then Nmap the hosts. A positive result is an unexpected open port such as 8443. - Panel information disclosure. Look for server info pages that reveal admin names. A positive result is a name that leads to a public repository.
- Credential reuse from leaks. Search employee repositories for
password,passwd,pwd,pass,pw,login. A positive result is a host, user and password combination that authenticates to the panel.
Glossary
- Bug bounty programme: a scheme where a company rewards people for responsibly reporting security problems in its systems.
- Hall of fame: a public page listing researchers who reported valid issues.
- Duplicate: a report of a problem the company already knew about, so it is closed without a new reward.
- Accepted: a report the company agrees is a real, new issue.
- SQL: the language used to ask a database for data.
- Database: an organised store of data, like a very large spreadsheet.
- SQL Injection: tricking a site into running your own SQL by feeding it through an input field.
- Parameter: a named value sent to a server, such as
username=orwa. - Endpoint: a specific address on a server that performs one job.
- Authentication: proving who you are, usually with a username and password.
- Authentication Bypass: getting in without proving who you are.
- Privilege: a permission an account has.
- Privilege Escalation: going from low or no permissions to high ones.
- XSS (Cross-Site Scripting): getting your own JavaScript to run in other people's browsers through a website.
- Reflected XSS: the malicious snippet comes straight back in the response to the same request.
- Stored XSS: the malicious snippet is saved on the server and served to every visitor.
- JavaScript: the programming language that runs inside web browsers.
- HTML: the language web pages are written in.
- SSTI (Server-Side Template Injection): making a server execute template instructions you supplied.
- Template: a page with blanks that the server fills in with data.
- Jinja2: a popular template engine for Python.
- RCE (Remote Code Execution): running your own commands on someone else's server over the network.
- Shell: a way to type commands directly to an operating system.
- Bind shell: the victim machine listens and the attacker connects in.
- Reverse shell: the victim machine connects out to the attacker.
- Subdomain: a prefix on a domain name, such as
mail.example.com. - Port: a numbered door on a computer that a service listens on; web traffic normally uses 80 and 443.
- HTTP / HTTPS: the protocol browsers use to fetch pages; HTTPS is the encrypted version.
- GET request: an ordinary page request, with data in the address.
- POST request: a form submission, with data in the body.
- Header: a small label attached to a web request or response, such as
Content-LengthorLocation. - Content-Length: a header saying how many bytes of body follow.
- Status code: a number in the response saying what happened; 200 means OK, 302 means redirect.
- Redirect: the server telling the browser to go to a different address.
- TLS certificate: a website's digital ID, containing the names it is valid for.
- CN (Common Name): the field in a certificate holding the domain name.
- Dorking: using advanced search filters to find exposed information.
- Fuzzing: trying many inputs automatically to see which cause interesting behaviour.
- Wordlist: the list of names or words a fuzzing tool tries.
- Spidering: letting a tool crawl a site and collect every link and page it can reach.
- Fingerprinting: identifying which software and versions a site runs.
- Default credentials: the factory username and password a product ships with.
- AWS (Amazon Web Services): a large cloud provider where companies rent servers.
- Shodan: a search engine for internet-connected devices and servers.
- Burp Suite: a tool that sits between your browser and a website so you can read and rewrite traffic.
- Match and replace: a Burp feature that automatically rewrites parts of requests or responses.
- Burp Collaborator: a service giving you a unique address so you can tell when a target contacts you.
- sqlmap: a tool that automates SQL injection testing.
- tplmap: a tool that automates template injection testing.
- Acunetix: a commercial automated vulnerability scanner.
- reNgine: a free alternative scanner mentioned by the author.
- Nmap: a tool that reports which ports are open on a host and which services listen on them.
- httpx / httprobe: tools that check which hostnames in a list actually answer over HTTP or HTTPS.
- Amass: a tool for discovering subdomains.
- FFUF / Dirsearch: tools that try a wordlist of file and folder names against a website.
- Wappalyzer: a browser extension that identifies the technologies a site uses.
- crt.sh: a public search engine for TLS certificates, useful for finding subdomains.
- GitHub: a website where programmers store and share code.
- Git: the version-control program used to download and track code.
- Organisation (GitHub): a shared account under which a company publishes code.
- MySQL: a popular database program.
- Python: a popular programming language.
- PHP: a programming language commonly used for websites.
- FTP / LDAP: older protocols for file transfer and directory services.
- 2FA (two-factor authentication): asking for a second proof of identity after the password, usually a code from your phone.
- Bucket: a storage container in a cloud service.
- Unsanitised: used as given, without checking or neutralising it first.
- Parameterised query: sending data to a database separately from the instruction, so it cannot be read as code.