Helpful first: Who may act in a cloud account · Trust boundaries: the server decides
Thirty days to Halcyon · Case 12: The long list · Episode 2 of 5
Monday afternoon. Dax Mercer, Software Engineer on the operations tools team, shows you pass-. It runs on every new object under halcyon- and writes a one-page summary. He wrote it in an afternoon.
Kael Cho, Staff Infrastructure Engineer, reads its policy. "You copied the node role's old policy."
"It works," Dax says. "And there's no server to break into." Kael uploads a test object with . in its name. The summary lands outside reports/. What else could this function do?
By the end you can
- Say which parts of a serverless function the provider secures and which stay with the customer
- Scope a function's execution role to the one resource and action its job needs
- Treat event data that triggers a function as untrusted input
What the provider runs, and what stays yours
A serverless function is code that the provider runs when an event arrives. pass- runs on AWS Lambda, in the same account as halcyon-. Nobody at Meridian logs in to the machine under it, or even knows which machine that is.
The provider takes over a lot. For a managed runtime, Lambda patches the operating system and the language runtime. It starts, stops, and replaces the environments the code runs in. This is shared responsibility with more of the work on the provider's side.
Four things stay with Meridian. The code and every library packaged with it are Dax's to update. The execution role decides what the function can touch. The trigger decides what can start it. The data it reads is only as trustworthy as whoever wrote it.
If Dax packaged his own runtime or a container image instead, patching that would be Meridian's job too.
SORT IT OUT
Dax lists five jobs for pass-report-export on Lambda's managed Python runtime. Who does each one?
Show the answers
- AWS. On a managed runtime, Lambda patches the operating system.
- AWS. Lambda keeps managed runtimes up to date with patches.
- Meridian. Anything in the deployment package is the customer's to update.
- Meridian. The execution role is written by the customer.
- Meridian. Validating event data is part of the customer's code.
The execution role is the function's whole authority
Set the function beside an ingest node again, a server that Meridian runs itself. Two jobs moved to the provider. The other four did not move at all.
The most important of the four is the execution role. When the function runs, Lambda takes on this role and hands the code temporary credentials for it. Everything the function can do in the account comes from that role. A function is as powerful as its role.
Dax copied the node role's policy before Kael narrowed it that morning. So his copy still allowed s3:* on every bucket. The job needs two actions. It reads each new object under halcyon- and writes one summary under halcyon-.
Every other permission is reach that only a bug or an attacker would use. Least privilege for a function means the role lists those two actions on those two prefixes, plus writing its own logs.
WORKED EXAMPLE
Narrow the role to the job
- List the job. Read one object under
incoming/. Write one summary underreports/. Write its own logs. - Write the grant.
s3:GetObjectonhalcyon-.downlink/ incoming/ * s3:PutObjectonhalcyon-. Log writing for its own log group only.downlink/ reports/ * - Count what went. The copied policy allowed every S3 action on every bucket, including deletes and changes to bucket policies. The new one allows 2 S3 actions, each on one prefix.
- Test it. Kael uploads his
.test object again. The function tries to write outside. / reports/and gets access denied.
Result: The function still does its whole job. The . bug is still in the code, but the role no longer lets it write anywhere else.
An event is input from whoever wrote the object
A function's trigger is an event, and the event carries data. When an object lands in incoming/, the event tells pass- the bucket, the object's full name, and its size. The trigger covers incoming/ only. On the whole bucket, every summary the function wrote would start it again, in a loop.
Dax's code builds the summary's name from the object's name. It takes the part after incoming/ and puts it after reports/. A path helper then tidies the result, and it resolves . as "go up one level". So an object named incoming/ produces a summary at status/, outside reports/.
Anyone who can write to incoming/ chooses that name. The upload is a trust boundary, and the event is untrusted input, like a form field on a web page.
So the code checks the name against the pattern a pass file uses and refuses anything else. The narrowed role is a second, independent layer. If a check is ever missed, the write outside reports/ still fails.
SPOT THE PROBLEM
This is part of the event that started pass-report-export for Kael's test object. Flag the fields whose values the uploader chose.
Show the answers
- object.key: incoming/../status/pass-118 The object's name is whatever the uploader typed, including ../ sequences.
- object.size: 48213 The uploader decides how many bytes to send, so the size is theirs too. Cap what the function will read.
A warm start can carry data over
Lambda does not always build a fresh environment for each event. After a run, it keeps the environment for a while in case another event arrives. A later run that reuses it is called a warm start.
Files written to / stay there between those runs. AWS documents this, and also says not to count on it. An environment may serve many runs, or be replaced at any time. So code must not assume / is empty, and must not assume it is kept.
pass- downloads each pass to / to read it. Dax's first version never deleted the files. A later run could find an earlier pass still on disk. A name bug like the . one could then read that pass into the wrong summary.
Kael asks for two small changes. The function deletes its file when each run ends. It also writes each download under a fresh random name, so one run never opens another run's file by accident.
CHECK YOUR JUDGMENT
Dax writes a second function, pass-archive-copy . It copies each new object in halcyon-downlink/incoming/ to a backup bucket. He asks which change matters most before it goes live.
CASE FILE · CASE 12 · ENTRY 2 OF 5
Answer the closing question correctly to add this entry to your case file.
A function is its role
A crafted object name moved pass-'s summaries outside reports/, and its copied every-bucket policy allowed that until its role was cut to reading incoming/ and writing reports/.
Next episode: Dax's function is narrowed. The 1,212 findings still need ranking.
Review sheet: exam notes and quick reference
Least privilege Granting each identity only the actions, objects, and time window required for the current job.
Trust boundary A place where identity, network, or data assumptions change and a fresh check is required.
Log A record emitted by a system that something happened, which may later be used as evidence.
Container A process run with its own view of the file system and resources, sharing the host's kernel.