On-ramp · Problems
Problems
★ foundations · ★★ advanced · ★★★ expert. Model answers are not published, so that the problems keep their value as assessment; the worked examples in the lessons and the capstone review are your feedback. Everything here runs offline with python3, curl and openssl, plus PyYAML (problem 3) and the cryptography package (problem 10).
-
★ In
POST https://crm.acme.example:8443@evil.example:9000/mcp?x=1, give the scheme, the userinfo, the host, the port, the path and the query. Which name does the TLS handshake check the certificate against? -
★ The gateway's JSON parser keeps the first value of a repeated key; the tool's keeps the last. For the body
{"to": "dana@acme.example", "to": "x@evil.example"}, who is the recipient according to the policy check and who according to the tool? Name two fixes and which one the tool still has to do for itself. -
★ Predict, then run with PyYAML's
safe_load, the type of each item in[no, "no", 1.0, 1.10, 0x10, ~, null, 010, "010", 1e3, 1_0, yes, y, off, 2026-10-15]. Which would you have got wrong, and which of them is a YAML 1.1 versus 1.2 difference? -
★ For each, say whether a bearer token may go there and what to do instead: a
?token=query string, a prompt, aAuthorizationheader set by the gateway, a structured log line of the full request, a.envfile in the repository. -
★★ Rebinding by count. A resolver answers the allowed name
files.acme.examplewith203.0.113.7on every odd-numbered lookup and10.0.0.5on every even-numbered one. Design A checks the name's address with one lookup, then lets the tool resolve it again. Design B resolves once, checks that address and connects to it. Out of 100 requests, how many reach10.0.0.5under each? Give the sequence for the first four requests of A. What changes if the resolver's answer depends on the time in seconds rather than the count, and the two lookups of design A are 20 ms apart? -
★★ Whose address? The origin sees peer
192.0.2.9, a proxy you run, andX-Forwarded-For: 10.0.0.5, 203.0.113.50, 198.51.100.7. The proxies you run are192.0.2.9and198.51.100.7. Which entry is the client, how do you find it from the right, and which entry would an allow-list of "internal clients" wrongly admit if it read the leftmost? -
★★ A wildcard. Make a certificate with
subjectAltName=DNS:*.acme.exampleas in lesson 7, run the client againstcal.acme.example,acme.example,a.b.acme.exampleand127.0.0.1. Report the four results and state the rule they show. What does the rule imply for an allow-list written as*.acme.example? -
★★ Write the verifier. Extend lesson 8's
verifywithnbfand a leeway of 5 seconds, and with a check thataudis a string or a list of strings. Write six tests, each of which fails for exactly one reason, and show they fail for that reason and no other. -
★★ Mint and break. With the lesson's key, mint a token whose
expis 24 hours afteriat. Your service's policy is "no token lives longer than 5 minutes". Where does the check belong in the order of lesson 8, and why is it not the same kind of check as expiry? -
★★★ Key confusion, end to end. Generate an RSA key pair with the
cryptographypackage. Writenaive_verify(token, public_pem)which readsalgfrom the header and supports RS256 and HS256 (withpublic_pemas the HMAC secret for HS256). Forge a token as another subject using only the public key. Then writeverifythat fixes the algorithm per key, and show the forged token and a genuine one against it. -
★★★ Count the mints. An agent makes 40 tool calls a minute to three servers, evenly. Module 12 mints a five-minute token per call. How many tokens does the authorization server issue per hour? Suppose instead the gateway caches one token per server for four minutes. How many, and what do you lose (use the properties of lesson 4)? What could an attacker who steals a token at a random moment do under each, and for how long, on average? Finally, suppose each token is DPoP-bound to the gateway's key (lesson 4): which of your answers change, and what must the attacker steal instead?
-
★★★ Read the whole chain. Module 3, lesson 10 (the sequence diagram with
401,resource_metadataand theresourceparameter) uses nearly every term of this unit. Annotate each step with the lesson here that explains it, and name one step for which this unit's lessons are not enough. -
★★★ Prove one parser, find the other. Lesson 2's gateway rejects duplicate keys and forwards
json.dumpsof what it parsed. (a) State the property of the tool's parser that makes this design sound (lesson 10's condition with the gateway's output in place of x), and list the features ofjson.dumps's default output that a tool's parser must read as Python does for the property to hold. Find one default that a JavaScript parser reads differently, and the setting that removes it. (b) Write a differential test that sends 10,000 generated JSON texts, with repeated keys, large integers, non-finite numbers,\u0000and lone surrogates, to Python'sjson.loadsand to one other parser you have (a second language, orjson.loadswith a customobject_pairs_hook), and report the members of the differential set you found by kind. (c) Explain why a run that finds nothing would not be evidence that the design is sound, and what is the evidence. -
★★★ An agent's OAuth, audited against RFC 9700. An agent framework lets a user add any MCP server by URL. For each server it fetches the resource metadata, discovers the authorization server, registers itself there, runs the authorization code flow with PKCE through one fixed redirect URI
http://localhost:7777/cb, stores refresh tokens on disk without rotation, and sends the access token on every call to that server. (a) For each of RFC 9700's attackers A1 to A5, say whether this deployment faces it, and how. (b) Name the precondition of the mix-up attack that the design meets, and the two changes, either of which removes it, with their costs. (c) The access tokens are audience-restricted but bearer. A malicious server the user added keeps every token it receives. What can it do with them, where, and for how long? Which single requirement of lesson 11's table would end that? (d) The framework's issuer rotates its signing key every 30 days, verifiers cache the key set for 12 hours, access tokens live 10 minutes and clocks differ by up to a minute. Give the publication schedule, and the refetch rule you would give verifiers, so that a routine rotation fails no valid call, and an emergency one fails only calls carrying tokens signed with the withdrawn key, for at most one access-token lifetime. What must clients do on a401for that bound to hold?