unicodeveloper / unicodeveloper/globalthreatmap

NEXT_PUBLIC_MAPBOX_TOKEN` baked into the Docker image at build time

Open
#32 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.8k
Forks
300
PR merge metrics
No merged PRs in 30d

Description

  • Context: Cloud
  • Category: Secret Leakage
  • Severity: 🔴 Critical

Evidence

# Dockerfile
ARG NEXT_PUBLIC_MAPBOX_TOKEN
ENV NEXT_PUBLIC_MAPBOX_TOKEN=$NEXT_PUBLIC_MAPBOX_TOKEN
RUN pnpm run build

NEXT_PUBLIC_* variables in Next.js are inlined at build time into the JavaScript bundle. The Mapbox token is therefore embedded in the compiled static assets inside the Docker image. Any party who can:

  • Pull the Docker image from a registry (even a private one with a leaked pull token)
  • Extract the image layers with docker save or dive
  • Browse the .next/static/chunks/*.js files

will find the Mapbox token in plaintext. Unlike server-side env vars that exist only at runtime, this token cannot be revoked without a full rebuild and redeployment.

Additionally, ARG values are stored in the Docker image manifest history:

$ docker history <image> --no-trunc

This prints the value of each ARG used during RUN commands.

Impact: Permanent exposure of the Mapbox token in all distributed or stored image artifacts. Tokens used in CI/CD build args are also captured in CI logs unless explicitly masked.

Affected files: Dockerfile

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the affected Dockerfile and inspect how the Next.js build receives NEXT_PUBLIC_MAPBOX_TOKEN. Reproduce the exposure with docker history and by searching the generated .next/static/chunks/*.js assets. Done means the token no longer appears in image history or compiled static assets, with the build and deployment flow still working.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, next.js, typescript
Domain
build-system, devops, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.