Hardcoded Secret Extraction and Exploit Chaining

Stolen credentials open the door, but the exploit chain determines how far an attacker travels.

Correspondent · · 11 min read
Cover illustration for “Hardcoded Secret Extraction and Exploit Chaining”
Exploitation Techniques · September 21, 2026 · 11 min read · 2,365 words

A hardcoded secret is the front door for an attacker, not the finish line. It is the front door. Once a key, token, or password gets pulled out of a codebase, the real work starts: figuring out what that credential opens, what sits behind that door, and how far a single login can carry someone through a company's systems. The instinct to log a hardcoded secret as "low severity, rotate and move on" is exactly what makes it dangerous, because severity was never about the secret itself. The blast radius is what matters.

Start with what counts. API keys, OAuth tokens, database passwords, cloud access keys, private certificates, JWT signing secrets: these all qualify, and they all hide in the same handful of places. Source code. Git history. Container images. CI/CD logs. JavaScript bundles shipped to browsers. Mobile app binaries. .env files. Infrastructure-as-code configs. Astra Security, publishing in August 2026, found that over 25 million new hardcoded secrets appeared in public GitHub repos in 2025 alone, putting a number on the exposure. But volume isn't the scary part. The scary part is persistence. Astra Security reports that 60% of valid secrets found in 2022 were still valid four years later. Code moves on. The secret usually doesn't get rotated, and it just sits there, waiting.

What follows traces that chain step by step: how attackers pull secrets out faster than most teams realize, what a single stolen credential actually unlocks, how cloud IAM turns one leaked key into cross-account access, and why, by 2026, all of this happens on a timeline measured in hours, not weeks. It ends with what a real penetration test has to prove to make any of this useful for an audit.

How attackers find and extract secrets before a pen tester does

Nothing about secret extraction is exotic. It's mechanical, repeatable, and mostly automated, which is exactly why it works at scale. Attackers are running scripts against the same six or seven places developers keep leaving things in plain sight. They're running scripts against the same six or seven places developers keep leaving things in plain sight.

Single-page apps ship JavaScript bundles to the browser, and those bundles get minified, not encrypted. Hive Security's research describes simple grep-based trawls through that minified code, hunting for string patterns like api_key, secret, and token. It takes seconds per bundle.

Git history is worse, because deleting a file doesn't delete its past. A secret committed on day one and committed on day two is still sitting in the commit log a long time later. Open-source tools like TruffleHog and Gitleaks walk every commit in a repo's history looking for exactly that pattern.

CI/CD pipelines leak in a different way. Build output, artifact metadata, and pipeline environment variables get echoed into log streams, and anyone with read access to the pipeline can read the logs. Container images bake secrets into layers at build time, and those layers survive every future pull of that image, forever, unless someone rebuilds from scratch. Mobile apps get decompiled, and keys or tokens compiled directly into the binary come right back out (per Novee Security). And .env files and infrastructure-as-code configs get committed by accident constantly; cloud scanners just enumerate deployed environments until they find one.

None of this requires custom tooling. It's largely open-source, it's fast, and the pace of discovery has compressed dramatically. Turning on GitHub's native secret scanning helps, but it only catches known patterns from partner providers, leaving other exposures unaddressed.

Once the secret is in hand, the attacker isn't asking "what is this?" The question is: what does this unlock, and what can be reached from there?

The first pivot: what a single extracted secret unlocks

The gap between having a secret and having access is smaller than most developers assume. Often, there is no gap at all.

Take a JWT signing secret. If an attacker knows it, they can forge any token they want: no password, no brute force, no MFA to get past, because a forged token with a valid signature looks exactly like a real one to anything checking it. This is documented, not theoretical. CVE-2026-21858, nicknamed "Ni8mare," hit n8n through a Content-Type confusion bug that read /home/node/.n8n/config.json, pulled out the JWT secret, forged an admin session, then used expression injection to run OS commands directly in the daemon. FireCompass reported more than 26,500 internet-exposed instances and roughly 100,000 vulnerable worldwide. The forged token step is often invisible to perimeter monitoring, because structurally, it's a valid token. Nothing about it looks wrong.

Database credentials skip the forgery step entirely: direct read and write access to production data, and often a launchpad for moving somewhere else. API keys tied to third-party services (Stripe, Twilio, SendGrid) tend to carry more permission than the integration actually needed, because nobody scoped them down at setup time. That's not a bug, it's just how integrations get built under deadline pressure.

Cloud access keys are the most consequential first pivot of all in cloud-native environments, and the next section is entirely about why. For pen testing purposes, the distinction that matters is this: a scanner flags the secret. A pen tester proves the blast radius by actually attempting the pivot. Those are two different findings, and only one of them tells a company anything useful.

Cloud metadata and IAM: how a leaked key becomes cross-account access

In the cloud, a credential finding causes full organizational compromise rather than remaining "sensitive data exposure," because cloud access chains extend far past the initial data. Two paths lead here, and they converge on the same outcome.

Path one is direct: a hardcoded AWS access key sitting in source code or an environment variable gives immediate API access, no further exploitation needed. Path two runs through SSRF. A server-side request forgery vulnerability in a hosted app reaches AWS's Instance Metadata Service at 169.254.169.254 and pulls the instance's IAM credentials straight out. IMDSv1, still present in plenty of environments, doesn't even require a session token to hand those credentials over.

There's a documented example that walks through both file exposure and SSRF together. The Chainlit AI Framework carried two CVEs disclosed close together: CVE-2026-22218 allowed arbitrary file reads of anything the Chainlit service could access, including .env files, and CVE-2026-22219 was an SSRF flaw reaching internal network services and cloud metadata endpoints. FireCompass, in January 2026, laid out the resulting chain: cloud account compromise, S3 bucket enumeration, source code theft, and CI/CD pipeline poisoning.

Pen testers have a shorthand for this now: SSRF leads to cloud metadata, metadata leads to an IAM key, the key leads to a cross-account assume-role, and that leads to data leaving the building. Every arrow in that chain is testable and provable on its own.

Over-permissioned roles are the accelerant. Lambda execution roles and EC2 instance profiles routinely carry far more permission than any single task calls for, so one harvested credential can assume-role right into an adjacent account. And a related but distinct pattern is hardcoded secrets sitting in Lambda environment variables, visible to anyone who can describe the function. Tools like AWS Secrets Manager and HashiCorp Vault exist specifically because environment-variable secrets are this exposed by default.

What comes next isn't just a technical hop. It's a jump across organizational boundaries.

Lateral movement and privilege escalation once inside the cloud boundary

Getting into the cloud environment was always the staging ground for everything that follows, never the goal itself. It's the staging ground for everything that follows.

Palo Alto Networks' Unit 42 research, validated against the GTG-1002 espionage campaign and summarized by the Cloud Security Alliance in May 2026, documents a four-pivot kill chain that recurs constantly across incidents. First, initial access through a CVE or a hardcoded secret. Second, credential harvesting from whatever context that access lands in, whether that's environment variables, the metadata service, or config files. Third, lateral movement into privileged internal services: internal APIs, database endpoints, CI/CD systems. Fourth, data exfiltration through abused service account permissions.

What's new is who's running the chain, not the chain itself. It's who's running it. Unit 42's multi-agent system, called "Zealot," executed all four stages, from initial SSRF straight through to BigQuery data exfiltration, autonomously, from a single starting prompt, with no human touching the keyboard between pivots. The CSA's May 2026 report states that GTG-1002, a Chinese state-sponsored actor Anthropic attributed with high confidence, ran full attack chains in late 2025 with 80 to 90% of the tactical operations handled autonomously by LLMs.

The mechanics inside a cloud environment look consistent across these cases: assume-role into adjacent accounts using harvested IAM credentials, enumerate every S3 bucket and RDS snapshot and Secrets Manager entry the compromised identity can reach, abuse long-lived database service account credentials available to anything on the same network segment, and poison CI/CD pipelines to get code execution on every deployment going forward, not just the current one.

The same pattern occurs outside the cloud, too. The Windows DWM vulnerability chain, CVE-2026-20805, used a memory leak to defeat ASLR, let the attacker pre-calculate ROP gadgets, and then chained in secondary RCE bugs. FireCompass reported that success rates on those secondary bugs jumped from 5 to 10% on their own to over 90% once chained behind the memory leak. Chaining doesn't just add options: it turns a coin-flip exploit into a near-certainty.

Time matters here more than almost anything else. The Cisco AsyncOS zero-day, CVE-2025-20393, ran for roughly two to three weeks before anyone caught it: exploitation started in late November 2025, disclosure landed December 17. FireCompass's reporting notes that lateral movement to domain controllers occurred during that dwell period.

Why the chain assembles faster than defenders expect in 2026

The old assumption was that exploit chains needed a human at every pivot, checking output, deciding the next move. That assumption is dead.

University of Illinois research, cited by the CSA, found GPT-4 can autonomously exploit 87% of disclosed one-day CVEs. Patch velocity used to be scheduled maintenance. Now it's a race against the clock, and the clock is short. CVE-2026-42208, a pre-authentication SQL injection in LiteLLM with a CVSS score of 9.3, was under active exploitation within roughly 36 hours of its patch disclosure in April 2026. CVE-2026-44338, an authentication bypass in PraisonAI, was weaponized in under four hours of publication.

The CSA's 2026 reporting states that multi-agent setups make this worse by running reconnaissance, exploitation, and persistence in parallel sub-agents instead of in sequence. Work that used to take a skilled operator a day now finishes in minutes, unattended.

The structural fallout is straightforward: a hardcoded secret flagged as low severity at last year's annual pen test can be a fully exploited, fully chained compromise by the time next year's test rolls around. And the attack surface keeps growing to meet it. Google's Threat Intelligence Group found that 48% of all exploited zero-days in 2025 targeted enterprise technology, an all-time high, as reported by Novee Security. Nothing here is shrinking.

That speed gap is exactly what separates a pen test that catches something real from one that's just a compliance checkbox.

What a pen test must do to characterize a chain, not just detect a secret

A scanner answers one question: is a secret there? A pen test has to answer a harder one: where does it go?

Getting that answer requires whitebox access, full stop. Source code, git history, CI/CD configs, cloud configurations, the complete attack surface rather than whatever happens to be externally visible. Blackbox testing misses secrets sitting in commit history or environment variables by design, because it never looks there.

It also requires someone to actually attempt the first pivot. Forge the JWT. Call the IAM API. Try the assume-role. Automated scanners flag patterns; they don't execute anything. A finding without a demonstrated exploit is an estimate of severity. A finding backed by a forged admin token, a successful cross-account assume-role, or a retrieved database record isn't up for debate anymore.

Some firms run an automated scanner, wrap the output in a PDF, and call it a manual penetration test, a real methodology gap. A genuine manual test involves a tester making judgment calls, chaining individual findings together, and testing business logic, none of which a scanner can do on its own. Scope matters just as much. Secrets live in CI/CD logs, container images, and IaC files, so a test scoped only to the web application front-end misses the most common places secrets actually persist.

Certifications are a reasonable proxy for whether a tester can do this work. OSCP is a widely recognized certification for penetration testing practitioners. OSWE goes deep on web application exploitation specifically. GXPN covers advanced exploitation, including complex, multi-step attack scenarios. And at the reporting stage, human review isn't optional. AI-assisted tools can speed up enumeration, sure, but reconstructing the chain and assigning real severity needs a certified analyst who can tell a theoretical path apart from a proven one before it lands on an auditor's desk.

How chain-proven findings translate into audit-ready evidence

Thorough testing and audit-friendly reporting are not in tension. A chain-proven finding is stronger audit evidence, not weaker, because it replaces a guess with a demonstration.

SOC 2 is an attestation, not a certification. A licensed CPA firm issues an opinion on whether controls are designed effectively (Type I) or operating effectively over time (Type II), and a pen test report serves as evidence those controls got tested under real conditions, not just described on paper. Penetration testing itself is optional under SOC 2, but it's commonly used to support the Security, Availability, and Confidentiality criteria. Bright Defense's research points to where audits actually run into trouble: poor scoping, reports that are already stale, missing retests, and scan-only "testing" dressed up as something more.

A finding that traces the full chain, backed by a proven exploit and a documented retest, is exactly the kind of evidence that holds up under an auditor's questions. It shows a control failed, shows precisely how far that failure reached, and shows the fix actually closed the gap rather than just papering over the symptom. That's the difference between a report that sits in a drawer and one that actually earns the trust it's supposed to represent.

Sources

  1. Web Application Penetration Testing 2026: Beyond OWASP Top 10 — Hive Security
  2. Weekly Report: New Hacking Techniques and Critical CVEs 13 Jan- 19 Jan 2026
  3. LLM-Orchestrated Kill Chains: From CVE to Database Breach in Four Pivots
  4. Best Secret Scanning Tools in 2026 - Astra Security Blog
  5. Modern Application Penetration Testing
  6. brightdefense.com

More in Exploitation Techniques