Helpful first: A hardened baseline, and proof it held · Identity, proof, permission, and recovery
Thirty days to Halcyon · Case 14: The field laptop · Episode 4 of 5
Monday, 10:40. field- is released and clean. Nyx, the Threat Hunter, is still reading what the agent collected from the calibration tool's USB drive. One file on it is called ..
She opens it. One line holds the API key for sched-, the pass scheduler. The key was issued two years ago. The same line sits in the tool's code history.
Kael Cho, Staff Infrastructure Engineer, is already typing. "I'll rotate it. Two minutes." Nyx does not look up. Is a new key the end of it?
By the end you can
- Find secrets kept where they should not be, such as files, environment variables and code history
- Tell rotation from revocation, and order the steps after a leak
- Replace a long-lived secret with one a vault issues for a short time
Where secrets hide
A secret is anything that grants access just by being known: a password, an API key, a token, a private key. Whoever holds a copy can use it. So the first job is finding the copies.
Files are the usual place. A . file is a plain text list of settings that a tool reads when it starts. It is easy to copy, back up and forget. The . on the USB drive went wherever the drive went.
Environment variables come next. A tool can read a secret from its environment instead of a file. Every process it starts inherits that environment, and the values can turn up in logs and crash dumps. The OWASP Secrets Management Cheat Sheet advises against them unless nothing better is possible.
Code history is the one people miss. Deleting a key in a new commit removes it from the current files only. Every earlier commit still holds it, and so does every copy anyone cloned. Secret scanning tools search the whole history for this reason. Encoding does not hide a secret either. A value in Base64 looks scrambled, but anyone can decode it in a second.
SPOT THE PROBLEM
Nyx lists what the calibration tool's folder holds. Flag the lines that expose a secret.
Show the answers
- run.log: request sent with header Authorization: Bearer, followed by the full key A log line that holds the whole key is another copy of the secret. Logs get shipped, kept and shared.
- settings.json: password = Y2FsaWItdG9vbC1wYXNz That is Base64, which anyone can decode. It is a password in plain sight.
Rotating is not revoking
Two words get mixed up after a leak. Rotating issues a new secret and moves the tool over to it. Revoking tells the issuer to refuse the old secret. Some systems revoke the old secret as part of rotation. Many do not, and sched- did not, so check before you assume.
At 11:02 Kael rotated the key and moved on. Three minutes later, Nyx's test request with the old key was still accepted. Nobody had told the issuer to refuse it.
The OWASP cheat sheet lists the response in this order: revoke, rotate, delete the exposed copies, and keep a record of the secret's life. Revoking first may stop a tool for a few minutes. That costs less than a leaked key that still works.
Deleting the copies tidies up. It un-leaks nothing, which is why it never comes first. Then look back. The issuer's logs show the requests made with the old key. Any use nobody can explain is an incident of its own.
WORKED EXAMPLE
Looking back: who used the old key?
- Filter by key. Nyx searches the
sched-logs for requests made with the old key. The logs go back 400 days and hold 3,906 such requests.api - Group by source. Three sources appear: the field laptops' station addresses, Kael's workstation, and one request at 11:05 from Nyx's own test.
- Match to known work. Every laptop request falls inside a scheduled calibration. Kael's requests come from the day he last changed the tool, which his commit history confirms.
- Write down the gap. The key is two years old and the logs cover 400 days. Nobody can say who used it in the first 330 days. That goes in the record too.
Result: No request in the 400 days came from a source Meridian could not explain. The leak is closed, and the gap is written down rather than assumed away.
PUT IT IN ORDER
A key is found in a file and in code history. Put the response in order.
- Search the issuer's logs for every use of the old key
- Issue a replacement and deliver it to the tool
- Revoke the leaked key so the issuer refuses it
- Send a test request with the old key and confirm it is refused
- Remove the key from the file and from the code history
Show the answer
- Revoke the leaked key so the issuer refuses it
- Send a test request with the old key and confirm it is refused
- Issue a replacement and deliver it to the tool
- Remove the key from the file and from the code history
- Search the issuer's logs for every use of the old key
Revoking ends the leak at once, and the test proves it. The replacement follows, then the copies are removed, as OWASP orders it. The log search can then take as long as it needs.
Lab / 7 records / 3 calls / 10 steps
The key in the ticket
Nyx runs a leak drill. A made-up key, plan-export, lets a caller read pass plans from plan-api. A copy sits in a support ticket's comments, and nobody knows it yet. It is Tuesday, 09:00.
Nyx watches plan-api's log as it is written. Kael holds the console that issues and revokes keys, and he is testing a planner change this morning. Each log line arrives at its own time, and each move you make costs minutes.
Place each log line as expected or suspicious use. At each call, choose the move that gets the leaked key refused before the last request, without taking the service down yourself.
Verdicts
Read the lab as text, with every path
Keys at the start
- The old plan-export key: Accepted.
Systems
- plan-api: Plan export service.
- pass-planner: Pass planner.
Verdicts
- Expected use: The caller and the pattern are ones the key is meant for.
- Suspicious use: Nobody can explain the caller or the pattern.
Every best call: old key refused
- Tuesday 09:00, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 09:00. It fetches the day's plan changes. Verdict: Expected use. The planner calls on the hour with this key, from its own address. Everything about it is what the key is for.
- Tuesday 10:00, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 10:00. It fetches the day's plan changes. Verdict: Expected use. The same caller, the same hour mark, the same request. Expected use looks boring.
- Tuesday 10:41, plan-api (plan export service). plan-api log: a request with key plan-export from 198.51.100.23, an address never seen before. It lists the names of all 40 pass plans. Verdict: Suspicious use. A new address, off the hour, asking for a list the planner never asks for. Someone other than the planner holds the key.
- Call at Tuesday 10:41: Have Kael revoke the key at his console. The best call. A revoke tells plan-api to refuse the key from every caller. The planner stops too until it has a new key, a few minutes against a leak that keeps going. The address is reading now, so a few requests land first. It takes hold at Tuesday 10:47.
- Tuesday 10:43, plan-api (plan export service). plan-api log: the same outside address downloads three pass plans with key plan-export. It happened 4 minutes before it reached you. Verdict: Suspicious use. The holder is now taking plans. Reads like this leave the station for good.
- Call at Tuesday 10:47: Have Kael issue a new key and set it in the planner's config only. The best call. The planner keeps its 11:00 run on a key that has never sat in a ticket. A new key does nothing to the old one, which only a revoke stops. It takes hold at Tuesday 10:55.
- Tuesday 10:44, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 10:44, off the hour. It fetches one pass plan. It happened 11 minutes before it reached you. Verdict: Expected use. Off the hour, but from the planner's own address while Kael tests his planner change. The caller is the one the key is for.
- Tuesday 10:45, plan-api (plan export service). plan-api log: the same outside address downloads six more pass plans with key plan-export. It happened 10 minutes before it reached you. Verdict: Suspicious use. Nine plans are out now. The address keeps going, and each call lands before your changes do.
- Call at Tuesday 10:55: The plans taken today, and that the 370 days before the log are unknown. The best call. The log speaks for 30 days, and the key was valid for 370 more that nobody can see. Writing that down keeps the record honest about what it knows. It takes hold at Tuesday 11:05.
- Tuesday 10:58, plan-api (plan export service). plan-api log: the same outside address asks for the other 31 pass plans with key plan-export. The key is refused. It happened 7 minutes before it reached you. Verdict: Suspicious use. Still suspicious: the request is the same, but the key no longer works. Nine plans left before the revoke landed, and no more will.
- Outcome: Old key refused. At 10:58 the outside address asks for the other 31 plans and is refused. Nine plans left before the revoke landed. The planner runs at 11:00 on a key nobody else has seen. The record lists what left today and the 370 days the log cannot show.
A different second call, "Put the old key back so the planner works at 11:00": all 40 plans out
- Tuesday 09:00, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 09:00. It fetches the day's plan changes. Verdict: Expected use. The planner calls on the hour with this key, from its own address. Everything about it is what the key is for.
- Tuesday 10:00, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 10:00. It fetches the day's plan changes. Verdict: Expected use. The same caller, the same hour mark, the same request. Expected use looks boring.
- Tuesday 10:41, plan-api (plan export service). plan-api log: a request with key plan-export from 198.51.100.23, an address never seen before. It lists the names of all 40 pass plans. Verdict: Suspicious use. A new address, off the hour, asking for a list the planner never asks for. Someone other than the planner holds the key.
- Call at Tuesday 10:41: Have Kael revoke the key at his console. The best call. A revoke tells plan-api to refuse the key from every caller. The planner stops too until it has a new key, a few minutes against a leak that keeps going. The address is reading now, so a few requests land first. It takes hold at Tuesday 10:47.
- Tuesday 10:43, plan-api (plan export service). plan-api log: the same outside address downloads three pass plans with key plan-export. It happened 4 minutes before it reached you. Verdict: Suspicious use. The holder is now taking plans. Reads like this leave the station for good.
- Call at Tuesday 10:47: Put the old key back so the planner works at 11:00. Not the best call. The old key is the leaked one. The planner runs, and so does the outside address. The planner needs a key nobody else holds. It takes hold at Tuesday 10:51.
- Tuesday 10:44, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 10:44, off the hour. It fetches one pass plan. It happened 7 minutes before it reached you. Verdict: Expected use. Off the hour, but from the planner's own address while Kael tests his planner change. The caller is the one the key is for.
- Tuesday 10:45, plan-api (plan export service). plan-api log: the same outside address downloads six more pass plans with key plan-export. It happened 6 minutes before it reached you. Verdict: Suspicious use. Nine plans are out now. The address keeps going, and each call lands before your changes do.
- Call at Tuesday 10:51: The plans taken today, and that the 370 days before the log are unknown. The best call. The log speaks for 30 days, and the key was valid for 370 more that nobody can see. Writing that down keeps the record honest about what it knows. It takes hold at Tuesday 11:01.
- Tuesday 10:58, plan-api (plan export service). plan-api log: the same outside address asks for the other 31 pass plans in one archive, with key plan-export. It happened 3 minutes before it reached you. Verdict: Suspicious use. The rest of the plans, in one request. If plan-api accepts the key, all 40 are out.
- Outcome: All 40 plans out. At 10:58 the outside address takes the other 31 plans. A leaked key works until plan-api is told to refuse it, however many new keys are issued. The record lists what left today and the 370 days the log cannot show.
A different first call, "Issue a new key and move the planner to it": all 40 plans out
- Tuesday 09:00, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 09:00. It fetches the day's plan changes. Verdict: Expected use. The planner calls on the hour with this key, from its own address. Everything about it is what the key is for.
- Tuesday 10:00, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 10:00. It fetches the day's plan changes. Verdict: Expected use. The same caller, the same hour mark, the same request. Expected use looks boring.
- Tuesday 10:41, plan-api (plan export service). plan-api log: a request with key plan-export from 198.51.100.23, an address never seen before. It lists the names of all 40 pass plans. Verdict: Suspicious use. A new address, off the hour, asking for a list the planner never asks for. Someone other than the planner holds the key.
- Call at Tuesday 10:41: Issue a new key and move the planner to it. Not the best call. The planner gets a new key. Nobody has told plan-api to refuse the old one, so the outside address keeps reading with it. It takes hold at Tuesday 10:47.
- Tuesday 10:43, plan-api (plan export service). plan-api log: the same outside address downloads three pass plans with key plan-export. It happened 4 minutes before it reached you. Verdict: Suspicious use. The holder is now taking plans. Reads like this leave the station for good.
- Call at Tuesday 10:47: Have Kael issue a new key and set it in the planner's config only. The best call. The planner keeps its 11:00 run on a key that has never sat in a ticket. A new key does nothing to the old one, which only a revoke stops. It takes hold at Tuesday 10:55.
- Tuesday 10:44, pass-planner (pass planner). plan-api log: a request with key plan-export from the pass planner's own address, at 10:44, off the hour. It fetches one pass plan. It happened 11 minutes before it reached you. Verdict: Expected use. Off the hour, but from the planner's own address while Kael tests his planner change. The caller is the one the key is for.
- Tuesday 10:45, plan-api (plan export service). plan-api log: the same outside address downloads six more pass plans with key plan-export. It happened 10 minutes before it reached you. Verdict: Suspicious use. Nine plans are out now. The address keeps going, and each call lands before your changes do.
- Call at Tuesday 10:55: The plans taken today, and that the 370 days before the log are unknown. The best call. The log speaks for 30 days, and the key was valid for 370 more that nobody can see. Writing that down keeps the record honest about what it knows. It takes hold at Tuesday 11:05.
- Tuesday 10:58, plan-api (plan export service). plan-api log: the same outside address asks for the other 31 pass plans in one archive, with key plan-export. It happened 7 minutes before it reached you. Verdict: Suspicious use. The rest of the plans, in one request. If plan-api accepts the key, all 40 are out.
- Outcome: All 40 plans out. At 10:58 the outside address takes the other 31 plans. A leaked key works until plan-api is told to refuse it, however many new keys are issued. The planner runs at 11:00 on a key nobody else has seen. The record lists what left today and the 370 days the log cannot show.
Every choice at each call
After the Tuesday 10:41 record: An unknown address is using plan-export to read pass plans. What do you do first?
- Have Kael revoke the key at his console (6 minutes, the best call). A revoke tells plan-api to refuse the key from every caller. The planner stops too until it has a new key, a few minutes against a leak that keeps going. The address is reading now, so a few requests land first.
- Issue a new key and move the planner to it (6 minutes). The planner gets a new key. Nobody has told plan-api to refuse the old one, so the outside address keeps reading with it.
- Delete the key from the ticket's comments (3 minutes). Whoever copied the key from the ticket still holds it. Deleting one copy tidies up and stops nothing.
- Switch off plan-api until you know more (20 minutes). That stops the outside address and the planner with it. Revoking the one key would have stopped only the first.
After the Tuesday 10:43 record: The outside address took three plans at 10:43. The planner calls again at 11:00 and needs a key that works. What do you do?
- Have Kael issue a new key and set it in the planner's config only (8 minutes, the best call). The planner keeps its 11:00 run on a key that has never sat in a ticket. A new key does nothing to the old one, which only a revoke stops. In the outcome: The planner runs at 11:00 on a key nobody else has seen.
- Put the old key back so the planner works at 11:00 (4 minutes). The old key is the leaked one. The planner runs, and so does the outside address. The planner needs a key nobody else holds.
- Post a new key in the ticket so the planner's team can find it (3 minutes). A ticket is where the old key leaked from. A key belongs only where the one tool that uses it reads it. In the outcome: The planner's new key sits in a ticket's comments, where the last one leaked from.
- Skip the planner's 11:00 run until the drill is over (1 minute). The planner loses a run it needs, and the old key's state does not change. A new key keeps the planner working. In the outcome: The planner misses its 11:00 run.
After the Tuesday 10:45 record: Nyx's search of plan-api's log goes back 30 days and finds this address only today. The key was issued 400 days ago. What goes in the record?
- The plans taken today, and that the 370 days before the log are unknown (10 minutes, the best call). The log speaks for 30 days, and the key was valid for 370 more that nobody can see. Writing that down keeps the record honest about what it knows. In the outcome: The record lists what left today and the 370 days the log cannot show.
- Nine plans, and no use of the key before today (5 minutes). A clean 30 days says nothing about the 370 before them. The record would claim more than the log shows. In the outcome: The record says the key was never used before today, which the log cannot show.
- Block 198.51.100.23 and record the leak as closed (10 minutes). An address is easy to change, and the key is what leaked. A blocked address says nothing about the key or the days before the log. In the outcome: The record calls the leak closed because one address is blocked.
- Write it up once the drill is over (1 minute). Details fade fast, and the record is what the next person reads. Write it while the log is open.
A drill runs on a script, and its times are assumptions. Real revokes can be faster or slower, and real logs show more addresses. The key, the address and the times are made up.
A vault stores, controls and records
A secrets vault is a service that holds secrets and hands them out. It does three jobs. It stores them encrypted. It checks a policy before it hands one over. And it records who asked for which secret, and when.
The third job matters most in an incident. Nobody could say who had copied the . file. A vault's audit log answers that question for every secret it holds.
A vault also needs to know who is asking, without yet another stored password, or the problem only moves. The caller proves what it is with something it already has. On field- that is the laptop's device certificate, the same one it shows at the station's network ports. In the cloud, workload identity does the same job: the platform gives each workload short-lived credentials.
The keys that protect the vault itself need care too. NIST SP 800-57 Part 1 Rev. 5 (May 2020) covers key management, including how long each key may be used. Many vaults keep their own master key in a hardware security module.
Key in a .env file
- Copied wherever the drive goes
- No record of who read it
- Valid for two years
Secret from a vault
- Stored encrypted in one place
- Policy checked on every request
- Every request recorded
Better than storing a secret: issue a short one
A vault that stores a two-year-old key still holds a two-year-old key. The stronger move is to stop having long-lived keys at all.
A short-lived secret is issued for one job and expires on its own. Dynamic secrets go further. The vault creates the credential when asked and removes it when its lease ends. HashiCorp Vault's database engine, for example, creates a database login on request and revokes it when its lease runs out.
The calibration tool now works this way. When a pass is scheduled, it asks the vault for a token, and the laptop proves who it is with its device certificate. The token lasts one hour. If it leaks, it is useless an hour later. Nothing is stored on the USB drive to leak.
- Pass scheduledThe only time a token is issued
- Laptop proves itselfWith its device certificate
- Vault checks policyAnd records the request
- One-hour tokenExpires on its own
- sched-apiAccepts the token until it expires
SORT IT OUT
Nyx sorts what the calibration tool touches. Which are long-lived secrets, which are short-lived, and which are not secrets at all?
Show the answers
- Long-lived secret. It works until someone revokes it. Two years is a long time to be copied.
- Short-lived secret. It is still a secret. A copy stops working within the hour.
- Long-lived secret. Base64 is encoding. The password works until someone changes it.
- Not a secret. Knowing an address grants nothing.
- Not a secret. Public certificates are meant to be shared.
CHECK YOUR JUDGMENT
A deploy token is found in a public repository's history. An hour ago the team deleted the file in a new commit and issued a new token. What has to happen next?
CASE FILE · CASE 14 · ENTRY 4 OF 5
Answer the closing question correctly to add this entry to your case file.
Rotated is not revoked
The old sched- key still worked three minutes after Kael rotated it, and was refused only after he revoked it at 11:06.
Next episode: No stored key is left. The controller field-07 must reach cannot even be patched.
Review sheet: exam notes and quick reference
Log A record emitted by a system that something happened, which may later be used as evidence.
Incident An event or set of events that actually or potentially causes a security loss requiring coordinated handling.
Secrets management Storing, rotating, and auditing passwords, keys, and tokens so they are not copied into chat or source.
Key management The work of creating, storing, distributing, rotating, revoking, and destroying cryptographic keys, with a record of who may use each one. Encryption protects data only while its keys are controlled.
HSM A dedicated hardware module that generates and stores cryptographic keys and performs operations with them inside itself. Applications send it data to sign or decrypt and do not receive the key.
Certificate A signed document that binds a public key to a name, such as a server hostname, and states who issued it and for how long it is valid.
Workload identity An identity given to software, such as a server, function, or pod, that receives short-lived credentials instead of a stored secret.