StackBadger: how a pentest harness built inside another repo became a public tool
StackBadger is a security testing harness I built inside my TariffRefunded repo and later published as its own public repo, and three moments from its history are worth reusing.
- The first real run found 129 problems in the product and showed that bugs in the harness itself had been hiding 104 test results.
- I checked whether the tool could work out an app's login service from its front-end code, found it could not, and added a test that fails if anyone adds that guess back.
- Code review of the new check that confirms which site you are testing found a way around it, and the fix landed the same day.
StackBadger is a black-box penetration-testing harness: automated attacks that hit a deployed web app from the outside, with no source code and no server-side secrets. I built it inside the repo for TariffRefunded, another product on this register, and later published it as its own repo. This post covers three moments from that history that I would reuse on any security tool.
The first real run found bugs in the harness as well as the product
The first commit landed on May 4, 2026. By May 6 the first real run had led to two fixes: one remediating 129 findings in the product the harness was attacking, and one resolving bugs in the harness itself that had been hiding 104 test outcomes. Bugs like that turn a harness into a smoke detector with a muted speaker in some rooms: nothing sounds, and you can't tell whether that is because nothing is burning.
Moving everything product-specific into a profile
So that the harness could test other apps, a portability pass on May 5 removed its hardcoded TariffRefunded knowledge. Today every target detail comes from a profile, a YAML settings file that names the target's login provider (the hosted service an app uses to sign people in), database, storage and payment processor. By the June release the harness had adapters for four login providers: Clerk, Firebase Auth, Supabase Auth and NextAuth.
Why the harness can't spot Supabase Auth in an app's code
Supabase is a hosted Postgres database that also offers its own login service, Supabase Auth. A list of open items written on June 10 asked whether a run without a profile could detect Supabase Auth on its own, so a Supabase Auth target would stop being treated as Clerk. The obvious tool is a fingerprint: a string in the JavaScript bundle (the front-end code a browser downloads) that only a Supabase Auth app would contain.
The idea was checked against TariffRefunded's bundle, which uses Clerk for login and Supabase only as its database. Every candidate string was already there: gotrue, the name of Supabase's auth server, 37 times, plus signInWithPassword and auth/v1. The Supabase client ships that library code whether or not the app uses its login, which is like deciding a car has a sunroof because the owner's manual has a chapter on sunroofs. The one path that would give a Supabase Auth app away, /auth/v1/token, never appears in one piece, because the client assembles it at runtime. A fingerprint built from those strings would have labelled TariffRefunded itself a Supabase Auth app, so none was added and the --profile flag stayed required.
A test that fails if someone adds a Supabase Auth fingerprint
The README explains the limitation, and a test feeds the detector only the misleading library strings and asserts that nothing is detected. Its docstring (the comment at the top of the test) records the investigation. It runs in the offline job of CI (continuous integration, the checks GitHub runs on every push and pull request), which never touches a live target. Here is the pattern, simplified and generalised; this is not the product's code:
# Simplified sketch, not the product's code.
import unittest
# A signal is allowed only if an app that skips the login feature could never ship it.
SIGNALS = {"example-auth": "ExampleAuthProvider.mount("}
def detect_auth_provider(bundle: str):
for provider, signal in SIGNALS.items():
if signal in bundle:
return provider
return None
# Strings the database client bundles even when its login features are unused.
LIBRARY_ONLY_BUNDLE = "authclient ... signInWithPassword ... auth/v1"
class TestProviderNotDetectedFromLibraryStrings(unittest.TestCase):
"""Library strings were ruled out as a signal. Read the investigation before changing this."""
def test_library_strings_alone_identify_nothing(self):
self.assertIsNone(detect_auth_provider(LIBRARY_ONLY_BUNDLE))
def test_real_signal_still_detected(self):
self.assertEqual(detect_auth_provider("ExampleAuthProvider.mount(app)"), "example-auth")
if __name__ == "__main__":
unittest.main()
Use this when you rule out a shortcut that a teammate or a coding agent is likely to try again: adding "auth/v1" to the signals turns the first test red and sends whoever did it to the reasoning before the shortcut ships.
Publishing the harness as its own repo
The harness went public on June 10 as StackBadger, under the MIT open-source license, with thirteen attack-category modules at release, among them IDOR (insecure direct object reference: reading another customer's records by changing an ID in a request). The export followed a written checklist kept in the TariffRefunded docs: take only committed files with git archive from the main branch, scrub brand references, decode every string starting eyJ (the opening of a JSON Web Token, a signed login token) to confirm it is synthetic test data, and start the public repo from a clean git init. The checklist is manual, and nothing in CI enforces it.
Two gates on the run script, and a bypass found in review
On June 11, the day after the first public commit, two gates went into the run script, run.sh. Each is an environment variable that must exactly match the target's host. Both are required for any host other than localhost, and passing --yes doesn't get around them.
read-only probes, no writes to the target--full on the command line, plus @pytest.mark.write_probe on each write testexport CONFIRM_TARGET=app.example.com CONFIRM_AUTHORIZED=app.example.comdoctor.py checks the env file and test accounts before a runWhat the gates ask you to affirmThe security policy says to run StackBadger only against systems you own or are explicitly authorized, in writing, to test.
Code review that day found a top-severity bypass. A URL can carry a username before an at-sign (https://user@host) and a fragment after a #. The host check stripped the username part first, so for https://good.com#@evil.com it treated everything before the at-sign as a username and read the host as evil.com. The HTTP client, which sends the actual requests, still connected to good.com, so the gate could approve one host while the attacks went to another. The fix, which strips the fragment before looking for an at-sign, landed the same day.
The public repo today
By November 2026 the public repo had 105 commits and 23 test categories, and since July 15 its CI has also checked Python dependencies against published vulnerability lists with pip-audit. The code is at github.com/Doogit/StackBadger.
If you build a gate that compares hosts, test it with strange URLs as well as normal ones, and parse the address in the same order your HTTP client does, since that difference in order is what let this bypass through.