Skip to content

Quiz: Secrets and Configuration

Test your understanding of API keys, environment variables, leak paths, key rotation and the trailing newline trap with these review questions.


1. What is an env example file such as .env.example?

  1. A copy of the production .env kept for emergencies
  2. A committed file that lists every variable the app needs, with blank or fake values
  3. A file the hosting platform writes after each deploy
  4. A backup of the vault stored in the repository
Show Answer

The correct answer is B. The example file is always committed, and it holds the names of every setting with no real values. It tells a new helper or a fresh agent session what the app needs. The real .env file holds the values and is never committed. Options A and D would put secrets in the repository, which is exactly what the example file avoids.

Concept Tested: Env Example File

See: Env Example File


2. What is secret rotation?

  1. Moving a secret from one file to another in the codebase
  2. Encrypting a secret before committing it
  3. Changing which team member holds the vault password each month
  4. Replacing a secret with a new one everywhere it is used, then revoking the old one
Show Answer

The correct answer is D. Rotation is revoking with a replacement ready first: create the new key, put it everywhere the app reads it, confirm the app works, then revoke the old key. The app keeps running and the old value becomes useless. Moving a key between files (A) leaves it valid. Encrypting and committing (B) still copies the secret. Option C describes a team routine, not rotation.

Concept Tested: Secret Rotation

See: When a Key Leaks: Revoke and Rotate


3. A committed file held a live key. The builder deleted the file in a later commit. Why is the key still exposed?

  1. Git keeps every earlier commit, so the key is still in the history and in every clone
  2. Deleting a file in git only hides it on GitHub's website
  3. The key is still exposed only if the repository is public
  4. It isn't exposed: deleting the file removes it from history
Show Answer

The correct answer is A. Git's whole job is to keep every save point, so the old commit still holds the key, on GitHub and in every laptop and agent copy that cloned the repository. Option C is wrong because private repositories are copied too. The fix is to treat the key as leaked and rotate it. Rewriting history can tidy the record but can't recall copies already made.

Concept Tested: Secret in Git History

See: Secret in Git History


4. An app keeps showing "no data" for records the builder knows exist. The key looks correct on the settings page. What should be the first suspect?

  1. The vendor deleted the records
  2. The database needs a migration
  3. The key was stored with a trailing newline, so the vendor quietly rejects every request
  4. The front end is caching an old page
Show Answer

The correct answer is C. When a third-party API "returns no data" for data you know exists, first ask whether the vendor is accepting your key at all. A line break saved at the end of a key is invisible on a settings page, but the vendor sees a key that doesn't match and returns 401. If the code reads that failure as an empty result, the app shows "no data." Check with od -c, and trim values when the code reads them.

Concept Tested: Trailing Newline Trap

See: The Trailing Newline Trap


5. Why is a payment company's publishable key safe in front-end code when the secret key is not?

  1. The publishable key is encrypted by the browser
  2. The publishable key is made to be seen and can only start a checkout, not move money or read data
  3. Browsers block anyone from reading front-end code
  4. The publishable key expires every hour
Show Answer

The correct answer is B. Payment companies issue two keys on purpose. The publishable key is meant for the browser and can only do harmless things, such as opening a checkout page. The secret key can charge cards and issue refunds, so it stays on the server. Anyone can read front-end code with the browser's tools (C). The browser doesn't encrypt keys (A), and publishable keys don't expire hourly (D).

Concept Tested: Client-Side Secret Exposure

See: Configuration and Environment Variables


6. A live API key was committed to a private repository, and the vendor's usage page shows no calls the app didn't make. In what order should you act?

  1. Revoke the old key at once, then create a new one
  2. Delete the file from git, and leave the key alone
  3. Rewrite git history first, then decide whether to rotate
  4. Create a new key, put it where the app reads it, confirm the app works, then revoke the old key
Show Answer

The correct answer is D. With no sign of misuse, rotate without downtime: switch the app to the new key before the old one stops working. The order flips only when there are signs of misuse or the repository is public. Then you revoke first and accept a few minutes of a broken check. Deleting the file (B) leaves a valid key in history. Rewriting history (C) doesn't make the key useless.

Concept Tested: Secret Rotation

See: A Worked Example: Rotating the Committed Live Token


7. A helper asks you to "just send me the image-search key" so they can test something. What is the better answer?

  1. Paste it in a direct message, since direct messages are private
  2. Email it, then delete the email afterward
  3. Give them access to that one item in the vault, which you can take away later
  4. Commit it to a private branch they can read
Show Answer

The correct answer is C. A vault gives the helper access to one item without making a new copy, and you can take that access away later. When the key rotates, it changes in one place. Chat messages and emails (A and B) create copies on servers and devices you can't recall, and deleting your copy doesn't delete theirs. A commit (D) puts the key in git history, the hardest leak to clean up.

Concept Tested: Secrets in Chat and Email

See: Where Secrets Should Live: The Vault


8. What should you tell your agent so that a missing or malformed payment key is caught before any member tries to upgrade?

  1. "Add an env schema that checks every variable at start-up and stops the server if one is missing or wrong."
  2. "Log the payment key when the server starts so we can see it."
  3. "Wrap the payment call in a try-catch that ignores errors."
  4. "Hardcode a fallback key in case the variable is missing."
Show Answer

The correct answer is A. An env schema checks each value when the server starts, so a missing key, a key in quote marks or a test key in production stops the deploy with a clear message. Without it, the error shows up days later deep inside the payment code. Logging the key (B) creates a new leak. Ignoring errors (C) hides the problem. A hardcoded fallback (D) puts a secret in the code.

Concept Tested: Env Schema Validation

See: An Env Schema That Checks at Start-Up


9. In the dating-safety app, three leaks were found after launch: a live token in a source file, a whole .env committed, and a production .env sent by email. Why is each worse than the one before it?

  1. Each happened later, so more members were affected
  2. Email is encrypted less than git
  3. Each one exposes more secrets, and the last puts every production secret in a place nobody controls
  4. Each one was harder for a secret scanner to find
Show Answer

The correct answer is C. One token reaches one vendor. A committed .env holds every secret in the app, so every one needs rotating. A production .env sent by email holds the live keys, and the copy now sits on mail servers and devices you can't recall. The order is about how much is exposed and how far, not about timing (A) or scanner detection (D).

Concept Tested: Secret Leak Paths

See: The Three Leaks in the Running Example


10. You can add a secret scanner in three places: once over full history, before each commit on your laptop, and on every push in automatic checks. Why does the push check matter most over time?

  1. It is the only place a scanner can read git history
  2. It runs whether or not anyone remembers to set up a hook, so it doesn't depend on habit
  3. It finds secrets in the browser bundle as well
  4. It rotates leaked keys automatically
Show Answer

The correct answer is B. Every other habit in the chapter depends on someone remembering it. A laptop hook only runs on machines where someone set it up, and a one-time history scan finds only past leaks. A check on every push runs for every helper and every agent, every time. Scanners don't rotate keys (D), and the history scan also reads git history (A).

Concept Tested: Secret Scanner

See: A Secret Scanner