Security controls and supply chain
Layer supply-chain controls
AI supply-chain security protects the integrity and origin of datasets, dependencies, model checkpoints, tokenizers and configuration. Before accepting an artifact, record its source, immutable revision, expected digest, license, review status and maintainer. A hash detects bytes that differ from a trusted expected digest; it does not prove the supplier is trustworthy, the artifact is safe, or its license permits use. Verify publisher identity and signatures where supported, independently establish the expected digest, review permissions and license, scan dependencies and evaluate in an isolated environment. Pin revisions and keep rollback manifests. Treat unverified artifacts as quarantined, never load them merely to discover their contents. In the example the payloads are inert bytes, and the publisher and license flags stand for independent review. Matching bytes plus both flags return True; altered bytes and an unverified publisher return False. The function does not perform signature or license verification itself.
import hashlib
def artifact_allowed(payload, expected_digest, publisher_verified, license_reviewed): # Bytes are inert; digest comes from an independently trusted registry. return (publisher_verified is True and license_reviewed is True and hashlib.sha256(payload).hexdigest() == expected_digest)
expected = hashlib.sha256(b"fictional checkpoint A").hexdigest()print(artifact_allowed(b"fictional checkpoint A", expected, True, True))print(artifact_allowed(b"fictional checkpoint B", expected, True, True))print(artifact_allowed(b"fictional checkpoint A", expected, False, True))Separate integrity, provenance and behavior
Integrity means the bytes are unchanged relative to an independently trusted reference. Provenance records where the artifact came from and how it was produced. Behavioral evaluation checks whether the artifact meets defined requirements. A malicious artifact may have a valid digest if the reference itself was compromised; a signed artifact may still contain defects. Model formats and loaders differ in their risks; prefer reviewed non-executable weight formats where suitable, avoid unreviewed remote code and unsafe deserialization, and enforce isolation, limited network access and a read-only filesystem where possible. For data, verify permitted sources and transformations, record versions and inspect anomalous changes; no single statistical filter proves absence of poisoning. Review update diffs and use a known rollback version. Security controls cannot substitute for independent license or privacy review.
Protect resource budgets before dispatch
Rate limits control how often calls happen; per-request limits constrain the size or work of one call; cumulative quotas limit total exposure over a defined period. Apply input size, output token, timeout, tool-step and concurrency limits, and reserve capacity before dispatch. A request can obey a per-request cap but exceed the remaining account allocation. The example uses nonnegative integer units and a serial reservation rule: accept only when both requested units fit the per-request cap and total remaining capacity. Six used plus three requested is nine within a cap of ten; nine plus two exceeds the total, and five exceeds a per-request cap of four. Rejections leave usage unchanged. Zero units are valid in this toy accounting contract, not a reason to allow unlimited calls. Actual systems also rate-limit zero-cost work and use atomic reservations to prevent races. Reconcile actual usage and handle cancellation or ambiguous outcomes without assuming retries are free.
def reserve(used, requested, cap, request_cap): # Serial accounting simulation; units are hypothetical, not money. if any(type(x) is not int or x < 0 for x in (used, requested, cap, request_cap)) or used > cap: raise ValueError("invalid accounting state") if requested > request_cap or requested > cap - used: return (False, used) return (True, used + requested)
print(reserve(6, 3, 10, 4))print(reserve(9, 2, 10, 4))print(reserve(0, 5, 10, 4))Compare complementary defenses
Least privilege limits available actions, a sandbox restricts execution effects, input/output validation checks a contract, human approval confirms a particular permitted action, and monitoring detects anomalies. These solve different problems and should operate together. Separate read-only retrieval credentials from write credentials; enforce tenant permissions and egress restrictions in the trusted service. Prevent sensitive data from entering context when unnecessary; avoid relying on a model to redact everything after exposure. Fail closed when authority or policy state is missing. Use bounded retry policies with idempotency and monitor budget, denied requests, artifact rejections and latency. Quarantine suspicious updates, preserve redacted evidence and escalate to the named incident owner. Test a valid artifact and authorized action as well as rejection cases, and require independent review before production use. Passing local simulations does not establish actual sandbox isolation, concurrent accounting correctness or resistance to prompt injection.
Practice a defensive release decision
Use the Chapter 49 project to check a changed checkpoint, a missing publisher review and an oversized request. Document whether each can advance, which control rejected it, what minimal diagnostic is appropriate and what production tests are still needed. Create a small threat register with control owners and a residual-risk column. Do not download a model, run untrusted code, or perform a live attack. Reference: ref-ai-security-controls-and-supply-chain. Next: responsible AI, fairness, privacy and accessibility.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Security controls and supply chain quiz
Assess threat modeling, independent controls, artifact integrity and resource protection.
What does a matching digest prove within the fixture?
Why reject an artifact with missing publisher verification?
Used is 9, requested 2, total cap 10, request cap 4. What is returned?
What does a sandbox primarily constrain?
Why must production reservations be atomic?