Join our Newsletter — 33% off our NHI Course
Architecture & Implementation

Carrier

← Back to Glossary
By NHI Mgmt Group Updated September 29, 2026 Domain: Architecture & Implementation

A Carrier is the object returned by ScopedValue.where() that activates a binding when it is chained to run() or call(). If the Carrier result is discarded, the binding never becomes active, so later reads fail even though the code compiles and looks structurally complete.

What a carrier does

A carrier is the object that actually carries an activated ScopedValue binding into execution. It is a runtime handle, not the value itself, and the binding only becomes active when the carrier is chained to run() or call().

This makes carrier semantics unusually easy to misuse in otherwise well-formed code. The code can compile, the carrier object can be created, and the binding can still be absent at read time if the carrier is never invoked.

Why discarding the carrier matters

The key idea is that the carrier is not a passive container. It is the execution bridge that turns a scoped binding into observable state for the code that runs under it. If the carrier result is dropped, the binding never enters scope and later lookups behave as though no binding exists.

That distinction matters because the failure mode is structural, not syntactic. The call site may look complete, but the activation step is missing, so the defect often appears as an unexpected read failure rather than an obvious compile-time error.

How carrier activation fits scoped execution

Carrier-based activation is designed to make scoped values explicit at the point of execution. The binding does not spread globally, and it does not become active merely because the carrier was created. Instead, the carrier must be used to launch the target action so the binding is present only for that controlled execution path.

That is a useful safety property because it limits accidental propagation, but it also means the programmer must treat the carrier as part of the execution chain. In practice, the carrier and the runnable or callable form a single semantic unit.

Common failure patterns and what they look like

One common mistake is to treat the carrier like a configuration object and ignore its return value. Another is to assume binding activation happens eagerly at where(), when in fact the binding is deferred until the carrier is executed. A third is to refactor code in a way that separates carrier creation from invocation, which can silently remove the binding from the path that needs it.

These failures usually surface as missing context, failed reads, or behavior that differs between the scoped call path and the surrounding code. The bug is often subtle because the code structure still appears logically complete.

Risk and Threat Considerations

Discarded carriers create a reliability risk because the program may appear to have established a scoped binding when it has not. That can produce hard-to-diagnose failures in context-sensitive code, especially when the missing binding is only noticed much later in execution.

Failure mechanism: the carrier returned by ScopedValue.where() is never chained to run() or call(), so the binding never becomes active and reads occur outside the intended scope.

Impact: code that depends on the binding fails at runtime, often with behavior that is confusing because the setup code looked correct and the defect is easy to miss in review.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5, NIST CSF 2.0 and OWASP ASVS set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-2 — Identification and Authentication (Organizational Users)Scoped activation depends on authenticated execution context for the caller.
AC-6 — Least PrivilegeCarrier-bound scope limits where a binding is visible during execution.
Recommendation — Ensure the executing subject is identified and authenticated before relying on scoped context. Constrain execution paths so scoped data is only available where needed.
NIST CSF 2.0PR.AA-01 — Identity Management, Authentication, and Access ControlCarrier use is an access-control mechanism for making a binding available only to a specific execution path.
PR.PS-01 — Configuration ManagementCorrect carrier chaining is a configuration-sensitive code pattern that determines whether binding occurs.
Recommendation — Control access to scoped execution paths so bindings activate only when intended. Verify code paths and configuration state so carrier activation is not accidentally dropped.
OWASP ASVSV15 — Secure Coding and ArchitectureThe term describes a subtle code-structure requirement where correct invocation is essential to security-relevant behavior.
Recommendation — Design and review execution flows so deferred activation is explicit and not silently skipped.

Practitioner Guidance

What to watch for: treat carrier creation and carrier invocation as inseparable when reviewing scoped-value code. If you see where() without an immediate execution path, verify that the carrier is actually used, not just assigned or passed around.

Practitioner takeaway: a carrier only matters when it is consumed. In scoped execution, the invocation step is the point at which the binding becomes real.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 29, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org