← All tracks
FoundationsInformation Disclosure10 labsFoundation → Intermediate → Advanced4h practice

Information Disclosure: The Secret in the Leftovers

Secrets leak through deployment debris, not just endpoints.

“The site looked clean. The deployment left its diary in the web root.”

CWE-200OWASP Top 10 A01:2021OWASP ASVS 7.1
The mental model
Think like an operator, not a user: what did the deploy leave behind? Debug routes, environment files, backups, repository metadata, logs and headers are part of the attack surface.

A diagnostic route is shipped to production, a backup is placed in the web root, or a framework exposes an actuator. The route is not linked in the UI, but it is reachable and may return secrets.

We test features. Attackers test the debris around the features.

Threat model

What is actually at stake?

Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.

Assets

  • Secrets, API keys and connection strings
  • Internal hostnames, versions and architecture
  • Customer data in errors and logs
  • Source maps, backups and repository metadata

Actors

  • Unauthenticated scanner
  • Authenticated user probing error boundaries
  • Attacker who obtains a leaked artifact
  • Insider browsing public storage

Trust boundaries

  • Production to debug surface
  • Error detail to user response
  • Public storage to private build artifacts
  • Logs to customer-visible support tools

Abuse cases

  • Trigger a stack trace that reveals framework and file paths
  • Fetch .git, .env or source maps from the web root
  • Enumerate users through different error messages
  • Read internal headers that reveal proxy and service versions
PrerequisitesHTTP headers and status codesHow production builds differ from developmentBasic source control and deployment artifacts
Request anatomy

Follow the decision, not the payload

Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.

  1. 01

    Request

    An attacker sends malformed input, probes hidden paths or inspects normal responses.

  2. 02

    Leak

    The server returns a stack trace, header, build artifact or differential message that was never meant for the client.

  3. 03

    Learn

    The attacker maps versions, frameworks, internal hosts, file paths, user existence and secret formats.

  4. 04

    Chain

    The leaked detail enables a more precise attack, such as a known CVE or a targeted password reset.

  5. 05

    Persist

    The artifact remains cached, indexed or downloadable until someone removes it.

Case study

The build directory that answered every question

Composite case study from public disclosure patterns
Context

A composite case based on a common deployment mistake: a front-end build was copied to the web root with source maps, .git metadata and a staging environment file.

Discovery

A tester requested /source.map, then /.git/config and finally a backup file named after the release. Each returned 200 with production detail.

Impact

The artifacts exposed internal API routes, a staging token and the full client source. The token allowed read access to a staging tenant that shared a database with production.

Root cause

The deployment pipeline copied the entire repository instead of the build output, and the web server served dotfiles and map files.

Fix

Ship only the build output, block dotfiles and map files at the edge, rotate exposed secrets, and add a post-deploy artifact scan.

Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.

Attacker lens

A repeatable testing sequence

  1. Read robots.txt, sitemaps and JavaScript source for clues.
  2. Probe common deployment paths: debug, .env, backup, .git, actuator, metrics, logs.
  3. Compare 404s and error pages for framework fingerprints.
  4. Read the exposed artifact and extract the secret.

Where smart people get fooled

  • No link does not mean no route.
  • A 404 on one path does not mean the artifact is absent.
  • Production configuration is often copied from development.
Detection engineering

What would the logs show?

A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.

  • Requests for .git, .env, source maps, backups and editor files
  • Responses containing stack traces, SQL, internal paths or environment variable names
  • Different error bodies for existing and non-existing users
  • Unexpected Server, X-Powered-By or debug headers in production
  • Public storage objects with build or repository names
Starter query
index=web sourcetype=access_combined | eval probe=if(match(uri,"(\.git|\.env|\.map|backup|\.sql|\.zip|config\.json)"),1,0) | where probe=1 | stats count values(uri) by clientip, status | where status=200
The defender's move

Fix the decision, then prove it stays fixed

  • Remove debug routes and artifacts from production images.
  • Block dotfiles and backup extensions at the edge.
  • Use deployment checklists and automated exposure scanning.
Vulnerable patterntypescript
catch (error) {
  return Response.json({ error: error.stack, query: lastQuery });
}
Safer patterntypescript
catch (error) {
  const requestId = logServerError(error);
  return Response.json({ error: "Request failed", requestId }, { status: 500 });
}

Log detail belongs in the server log, keyed by a request ID. The client gets a stable, generic message and a way to report the ID.

Regression tests a reviewer would ask for

Error boundary

GivenA request triggers a server exception

WhenThe response is returned in production mode

ThenNo stack trace, SQL, file path or environment value appears

Dotfile and map

GivenThe app is deployed behind the edge

WhenA client requests .git/config, .env and a source map

ThenThe edge returns 404 and no artifact body

User enumeration

GivenLogin and password reset accept an email

WhenThe email exists and does not exist

ThenThe public response and timing are indistinguishable

Header fingerprint

GivenA production response is inspected

WhenThe client reads all headers

ThenOnly intentional headers are present; framework and debug headers are removed

False positives

What this finding is not

Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.

  • A version header is present but no known vulnerable component uses it: still reduce fingerprinting, but do not call it a breach by itself.
  • A 404 page looks custom: inspect the body, timing and headers for differences.
  • Source maps return 200 but contain only public code: verify whether internal routes or secrets are present before rating impact.
  • A stack trace appears only in a staging host: staging data and trust boundaries still matter.
Working vocabulary

Terms you should be able to use precisely

Fingerprinting
Learning the software, version and architecture of a target from observable responses.
Source map
A file that maps minified JavaScript back to original source, often revealing routes and comments.
User enumeration
Determining which accounts exist through differential responses or timing.
Stack trace
A diagnostic listing of function calls and file paths produced by an exception.
Secret sprawl
Credentials and keys spread across repositories, build artifacts and environment files.
Error oracle
A response difference that reveals hidden state, such as whether a record exists.
Interview drill

Answer these without reciting a payload

Why is a stack trace a security issue even without a direct exploit?

It reveals framework, versions, file paths and query structure that let an attacker select a precise exploit or bypass. It also often contains customer data.

How do you prevent user enumeration?

Use the same response shape, status and timing for existing and non-existing accounts, and move detailed decisions to async or internal logs.

What belongs in a post-deploy artifact check?

Dotfiles, environment files, source maps, backups, test data, repository metadata and build manifests should be absent from the public root.

Knowledge check

Can you separate the mechanism from the payload?

Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.

4 questions
01A 500 response includes a Python traceback with a database URL. What is the immediate risk?
02Which pair of responses most strongly suggests user enumeration?
03Why block .map files in production?
04What is the best client-facing error design?
الخلاصة الموسّعة
لماذا هذا مهم؟

تسريب المعلومات ليس ثغرة واحدة، بل سلسلة صغيرة من التفاصيل التي تصنع هجومًا دقيقًا: إصدار، مسار ملف، اسم جدول، أو رسالة خطأ تفرّق بين مستخدم موجود وآخر غير موجود.

أخرج التفاصيل إلى السجل الداخلي فقط، وأعد للعميل رسالة ثابتة مع رقم طلب. امنع الملفات المخفية وخرائط المصدر والنسخ الاحتياطية على الحافة، وراجع مخرجات النشر بعد كل إصدار. لا تنسَ أن فروق التوقيت أيضًا تُسرّب.

What did the deployment leave behind that the app never intended to serve?