17 Information flow
Page 1 of 11
The shipping-notice service of chapter 12 prints customers' email addresses in its log. Nothing stopped it: the address is a Text like any other. In Una you can say how sensitive a value is with a label, such as secret[PII], and the checker follows that label through every computation, every branch and every call. Labeled data reaches a log, a file or a service only if that place accepts its label. This chapter labels data, shows where the checker stops it, and releases what may legitimately go out through a declared policy.
What you'll build
The dispatch step of chapter 12, with the customers' names and addresses labeled as personal data. The mail service may receive them. The log may not, so it shows each address masked, through a policy that a reviewer can find in one place:
sent A-1001 to r***@example.invalid
sent A-1002 to t***@example.invalid
skipped A-1003: no customer has the id C-99
skipped A-1004: customer C-21 asked for no notices
skipped A-1005: the mail service did not answer; retry laterYou will learn to:
- label data with a level, such as
confidentialorsecret, and a category, such asPII; - predict the label of a result, including one decided by a branch;
- see which places accept which labels, and why data from outside is labeled;
- recognize data without keeping it, with a keyed hash, a
Hashed; - release data on purpose with a
policyin a trusted module; - read the U4xxx diagnostics and repair them without weakening the guarantee.
Download this chapter's packages: each step is a package under steps/, and the chapter's program is day-to-day/; run una check . and una run . in one.
Why it works this way
Many leaks of personal data are not attacks. A developer adds a debug line, an error message includes the request, a log line prints a whole record. Each change is small, and nothing in the language says that the value it prints came from a customer's record three calls away.
Una checks the flow of data as part of the type system:
- A label says how sensitive a value is. It is part of the type:
secret[PII] Textis a text that is secret and personal. A type without a label ispublic. - A result carries the labels of what it was computed from. That includes values chosen by a branch on labeled data, since the choice reveals the condition.
- Every place data leaves is a sink with a ceiling. The console accepts
publicdata. An operation of your own accepts what itsacceptsclause says. The checker proves, at every call, that the data is at or below the ceiling. - Lowering a label takes a policy. A policy names what it releases, to what label, through which function, for what purpose and with which owner. It lives in a trusted module, which
una.tomllists, and the build report lists every call.
What the checker guarantees is called noninterference, and it has a precise scope. An observer who sees only what reaches public places, such as the console, sees the same output from two runs whose labeled inputs differ, unless a policy released something. Timing, termination and resource use, among others, are outside that model (What the checker promises).
Labeled data leaves a program only through a place that accepts its label, or through a policy that a reviewer can read. The checker does not trust names, comments or intentions: it follows the data.