Threat Modeling Compound AI Systems › Step 3: Trace control flow and data flow
Language AI HandbookAll chapters A control-flow map shows who selects the next operation. A data-flow map shows which information is carried along each transfer. Here the application chooses a lookup, reads a record, and selects fields for the model. The record carries catalog data into the answer stage. It grants no new permissions. The renderer accepts a location proposal only after checking the source values. A proposal is data crossing the boundary to the renderer before that check.
PythonIn [6]Expand
operation_order = (
"bind reader identity",
"check read authorization",
"retrieve record",
"select fields",
"construct answer proposal",
"validate location and display",
)
assert operation_order.index(
"check read authorization"
) < operation_order.index("retrieve record")PythonIn [7]Expand
data_transfers = (
("Reader", "Application", "Authenticated request and title lookup"),
("Application", "Retrieval service", "Authorized catalog entry identifier"),
("Retrieval service", "Application", "Catalog record"),
("Application", "Answer model", "Selected public fields"),
("Answer model", "Renderer", "Proposed location"),
("Renderer", "Reader", "Checked location or unavailable status"),
)
for sender, recipient, data in data_transfers:
print(f"{sender} → {recipient} | {data}")ConsoleOut [7]Expand
Reader → Application | Authenticated request and title lookup Application → Retrieval service | Authorized catalog entry identifier Retrieval service → Application | Catalog record Application → Answer model | Selected public fields Answer model → Renderer | Proposed location Renderer → Reader | Checked location or unavailable status
A data-flow line does not describe the right to make the next decision. For example, the model sees the shelf field, but the renderer checks the proposal against the selected shelf value before displaying it. Keeping policy in the application also gives a reviewer a concrete place to inspect who may read a record when the session changes.
Follow information and decisions on separate maps
An arrow labelled location record can transfer data. An arrow labelled check read authorization transfers a request to evaluate a policy. They can refer to the same resource yet belong to different maps. If you merge the maps too early, it is easy to infer that a component carrying the record can authorize another lookup. Conversely a component that can authorize access does not necessarily need the full record for that decision. The authority map says who acts under whose permission. The data-flow map says which representation travels where.
The distinction becomes practical in a retry. A service might retry an authorized read after a timeout. The retry decision is a control-flow edge. The record received on success is a data-flow edge. If the user's visibility changes before the retry, the architecture needs a rule about reusing the previous authorization or consulting current state. Even if the retry eventually returns a record with the expected fields, the project still needs to check that its chosen rule was applied. A test focusing only on successful lookup values will miss the authorization question.
Table snapshots can be helpful when a diagram gets crowded. Freeze the scope to one request and record the executed operation sequence as evidence in a test. Record keys or types at each data crossing using toy values. Look for a place where the deployed path takes a different branch from the diagram. A difference can mean an incorrect implementation or a stale diagram. Investigate that difference before treating the model as a complete basis for design decisions.
The example below represents operations and data transfers as tuples because their order is declared. Tuple order expresses the route we intend to examine. The fact that the tuple puts a check before a lookup does not enforce that order anywhere else. The useful next inspection for a deployed app is to find the actual lookup call and verify which successful predicate leads to it.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!