Runtime Safety Provider Deployment Policy¶
Date: 2026-05-19
Status: - draft deployment policy - non-normative - intended for local shared-infra and small-network reference deployments
Purpose¶
Runtime safety is scan-time evidence. It is not issuer legitimacy, destination approval, or source-of-truth governance state.
This policy defines how live redirect, reputation, safe-browsing, and TLS/HTTPS inspection providers should be attached to the QR trust network without collapsing the paper's trust layers. A provider may downgrade or block a scanner decision when present-time destination evidence is risky. It must not make an unknown issuer trusted, approve a destination, or mutate durable trust state.
Placement¶
Runtime safety runs after the verifier has already resolved the QR artifact against the verifier cache:
- issuer legitimacy is evaluated from root, authority, issuer, and status state
- destination binding is evaluated against the issuer-approved destination policy
- runtime safety inspects current destination conditions
- the scanner maps the combined evidence into a user-visible decision
Destination binding remains terminal. A destination mismatch is not rescued by a later clean runtime-safety verdict.
Provider Boundary¶
Runtime-safety providers may inspect:
- normalized destination URL or destination host
- resolver URL and bounded redirect chain
- final destination host and final destination URL
- HTTPS/TLS presence and validation outcome
- malware, phishing, reputation, or block-list verdicts
- verdict freshness, provider version, and provider reason codes
Runtime-safety providers must not:
- enroll issuers
- approve destinations
- sign trust artifacts
- mutate root, authority, issuer, destination-policy, or verifier-cache source records
- turn an unknown issuer into a green scanner state
- require raw QR payloads, user identifiers, or session secrets unless a provider contract explicitly justifies that data
Required Verdict Shape¶
Live providers should normalize their output to the same contract used by the deterministic reference adapters:
clear: no current runtime risk was reportedrisky: elevated risk was reported, but no explicit block condition was reachedblocked: the destination should not be opened under current policyunavailable: the provider could not return a usable verdict
Each verdict should include:
- provider ID
- provider version when available
- checked-at timestamp
- freshness timestamp or provider TTL when available
- bounded reason codes
- sanitized destination fingerprint
- final host and redirect hop count when redirect inspection was performed
The scanner should expose concise user-facing state. Raw provider payloads are operator evidence, not ordinary scanner copy.
The persistable observation shape is defined in
runtime-safety-observation.schema.json. Deployments may store provider-native
payloads separately for operators, but scanner-facing and outbox-facing
evidence should use the normalized observation contract.
Decision Mapping¶
Runtime safety can strengthen or weaken a decision only inside the existing trust path:
clearcan contribute to green only when issuer legitimacy, destination binding, and verifier-cache freshness also passriskymaps to orange when issuer and destination binding pass but current destination risk is elevatedblockedmaps to red when an explicit block condition or local fail-closed policy is reachedunavailablemaps to orange by default because present-time safety could not be checked
Fail-closed red for unavailable is allowed only as a local policy decision for
high-risk issuer classes or regulated workflows. That policy must be visible in
operator configuration and scanner-decision reason codes.
Provider Classes¶
Redirect Inspector¶
A redirect inspector follows a bounded resolver chain and records:
- resolver URL
- final URL
- final host
- observed hop count
- hop-limit violations
- nested shortener detection
- resolver-to-final host mismatch
It should stop at configured hop limits and return a bounded reason code rather than trying to prove general URL safety.
Reputation or Safe-Browsing Provider¶
A reputation provider returns current known-bad, risky, or clear destination evidence. It should preserve provider freshness metadata and should avoid sending user identifiers or complete QR payloads when a host-level or normalized URL query is sufficient.
TLS/HTTPS Inspector¶
A TLS/HTTPS inspector records absent HTTPS, invalid certificate state, or other transport evidence. This evidence may raise risk or block according to local policy, but it does not replace issuer legitimacy or destination binding.
Privacy Controls¶
Deployments should minimize provider disclosure:
- prefer host-level queries when provider accuracy allows it
- send normalized URLs only when full-path context is required
- never send verifier API keys, signed payload secrets, or user identifiers to third-party runtime providers
- keep raw provider payloads out of scanner responses
- retain only bounded operator evidence needed for audit and troubleshooting
Failure Handling¶
Provider failures must not silently produce green.
Default failure mapping:
- timeout: orange,
runtime_provider_unavailable - provider auth failure: orange,
runtime_provider_unavailable - malformed provider response: orange,
runtime_provider_unavailable - explicit known-bad verdict: red, provider-specific block reason
- local fail-closed policy match: red, local policy reason
Provider credential compromise should disable that provider, mark verdicts unavailable, rotate credentials, and preserve durable issuer and destination state unchanged.
False positives should be handled by provider-specific review or override processes. Overrides must be scoped, audited, and time-bounded.
Caching¶
Runtime-safety verdicts may be cached for performance, but the cache is not durable trust state.
Cached verdicts should record:
- provider ID and version
- checked-at timestamp
- provider freshness timestamp or TTL
- destination fingerprint
- reason codes
- original verdict state
Stale runtime-safety cache entries should map to orange or trigger a fresh provider check. They must not silently preserve green.
Registered HTTPS provider acquisition¶
The packaged network worker image includes a one-shot operator command. It selects the static destination by ID from an active policy, verifies that the policy names the configured active provider, and checks that the provider's registered endpoint matches the operator-pinned HTTPS endpoint. The command sends the public policy URL without scan payloads, credentials embedded in the URL, query parameters, or fragments.
Set QRTRUST_NETWORK_DATABASE_URL, QRTRUST_RUNTIME_PROVIDER_ID,
QRTRUST_RUNTIME_PROVIDER_ENDPOINT, and QRTRUST_RUNTIME_PROVIDER_TOKEN_FILE.
The token file supplies the bearer credential only for that HTTPS endpoint.
The endpoint must support this JSON request.
The authenticated provider returns an application/json response with the
same URL, a verdict, an integer risk score from 0 to 100, a UTC check time,
and a positive TTL in seconds.
{
"destination_url": "https://acme.example/pay",
"verdict": "clear",
"risk_score": 0,
"checked_at": "2026-11-20T18:00:00.000Z",
"ttl_seconds": 60
}
The client caps the TTL at the provider registration's maximum, expects a current check time, limits the response to 8 KiB, and stops after three seconds. It does not follow redirects. An HTTP failure, timeout, malformed response, or mismatched URL publishes unavailable evidence. The command reports the observation verdict, observation ID, artifact hash, outbox event ID, observation time, and expiry. The outbox and runtime subscriber carry the scoped observation to Postgres. The receipt confirms publication was queued. Check the outbox and subscriber materialization before testing a scan.
npm run runtime:acquire -- \
--root-program-id root:qrtrust-demo:2026 \
--delegated-authority-id authority:qrtrust-demo:merchant-web \
--issuer-id issuer:acme-demo \
--destination-policy-id policy:acme-demo:web-payments:v1 \
--destination-id dest:acme-demo:pay
Each invocation requests one observation for one policy destination. This reputation adapter consumes provider verdicts for static URLs. Redirect-chain inspection is a separate provider capability.
Collector database credential¶
Apply Alembic through revision 20261120_0014 before starting the current
workers. Revision 20261120_0013 adds a nullable source artifact hash. The runtime
subscriber persists the verified hash and uses it to deduplicate deliveries.
Historical rows remain readable and keep a null source hash because their
artifact identity cannot be established from the materialized row.
Create a dedicated login and grant schema usage and execution of the two collector functions. The collector needs no table grants. Postgres checks the authenticated login against the operator-managed assignment before returning a destination and again before atomically appending its observation and event.
grant usage on schema qr_trust to qr_runtime_collector;
grant execute on function qr_trust.runtime_collector_target(
text,text,text,text,text,text
) to qr_runtime_collector;
grant execute on function qr_trust.publish_runtime_collector_observation(
text,text,text,text,text,text,text,text
) to qr_runtime_collector;
An operator adds one row to qr_trust.runtime_collector_bindings for each
approved destination. Set collector_role_oid from pg_roles.oid for the actual
database login. Set the root, authority, issuer, policy, provider, and
destination IDs. Record the provider's exact registered endpoint in
provider_endpoint, the exact policy URL in policy_url, and its canonical
HTTPS URL and hostname in destination_url and destination_host. Review and
update assignments if an endpoint or policy URL changes. During a cross-cluster
restore, recover these assignments using the captured role names.
Collector role restore procedure
With the API and NATS workers running, add compose.runtime-evidence.yml to
the same Compose project. Set QRTRUST_COLLECTOR_DATABASE_URL_SECRET_FILE and
QRTRUST_PROVIDER_TOKEN_SECRET_FILE to the collector's two secret files. Set
the provider ID and endpoint using the variables above.
docker compose -f compose.yml -f compose.nats.yml -f compose.runtime-evidence.yml \
run --rm --build network-runtime-collector \
--root-program-id root:qrtrust-demo:2026 \
--delegated-authority-id authority:qrtrust-demo:merchant-web \
--issuer-id issuer:acme-demo \
--destination-policy-id policy:acme-demo:web-payments:v1 \
--destination-id dest:acme-demo:pay
The collector exits after one request. The scanner service mounts only its database URL.
Review the destination before collection¶
With the stack already running, use the collector's --preflight flag to
review the assignment, exact canonical HTTPS destination URL, provider
endpoint, and registered TTL. Run the Compose container with --no-deps to
use the existing stack.
docker compose -f compose.yml -f compose.nats.yml -f compose.runtime-evidence.yml \
run --rm --no-deps network-runtime-collector --preflight \
--root-program-id root:qrtrust-demo:2026 \
--delegated-authority-id authority:qrtrust-demo:merchant-web \
--issuer-id issuer:acme-demo \
--destination-policy-id policy:acme-demo:web-payments:v1 \
--destination-id dest:acme-demo:pay
Preflight checks the local credential file and uses the collector's existing assignment lookup. The lookup releases its shared row locks when the database statement ends. Preflight returns before provider communication or publication. Provider authentication is verified during a live lookup.
For collection, omit --preflight and pass the exact reviewed URL as
--expected-destination-url 'https://acme.example/pay'. The collector
compares the supplied URL with the current assignment before sending any
request. The flag is required for Google Web Risk collection. Other
registered providers can use it as an optional check.
Google Web Risk Lookup pilot¶
Use an approved Google Cloud project with billing and the Web Risk API enabled. Restrict the pilot API key to Web Risk. Web Risk setup · API key restrictions
Register a separate runtime provider ID with endpoint
https://webrisk.googleapis.com/v1/uris:search. Use that provider ID in the
destination policy, collector assignment, and scanner runtime config. Set
QRTRUST_RUNTIME_PROVIDER_PROTOCOL=google-web-risk-v1 for the collector and
place the pilot's Web Risk API key in the existing provider token file. The
collector sends the key in the x-goog-api-key header to the pinned HTTPS
endpoint. Google API key guidance
The Lookup request discloses one exact, public destination URL from the approved
policy. It requests malware, social engineering, and unwanted software matches.
A current match produces blocked evidence with a lifetime bounded by Google's
expiry and the provider registration TTL. An empty reply object means none of
the requested lists returned a match. It produces scanner caution, with
no_match in the stored response status and web_risk_match: false in the
receipt. For failed or unusable responses, the receipt records
web_risk_match: null and the stored observation records the failure status.
Web Risk Lookup ·
Lookup response contract
Upgrade the runtime subscriber before collecting evidence with the new status.
The receipt query shows no_match alongside the coarse unavailable verdict
used by the scanner to show caution. Keep the collector receipts for pilot
review. Historical artifacts carry the status recorded at collection.
Restricted runtime subscriber¶
Apply migrations through 20261120_0014 and register the subscriber and its
QRTRUST_RUNTIME subjects before starting the worker. Create a dedicated
Postgres login and grant database connection if the environment restricts
it. Run the runtime subscriber grants
as the schema owner with that login's name in the runtime_subscriber_role
psql variable.
psql -X -v ON_ERROR_STOP=1 -v runtime_subscriber_role=qr_runtime_subscriber \
-f docs/public/network-contracts/reference-postgres-runtime-subscriber-grants.sql
These grants cover the authorization lookup, artifact lookup, observation insert, and the artifact hash lookup required for duplicate handling. Review inherited privileges for the login before deployment. The grants restrict operations and columns. The worker enforces the event's artifact ID, publication status, artifact type, and hash.
Set QRTRUST_RUNTIME_SUBSCRIBER_DATABASE_URL_SECRET_FILE to the file
containing that login's database URL and
QRTRUST_RUNTIME_SUBSCRIBER_NATS_PASSWORD_SECRET_FILE to the file containing
the authorized NATS user's password. Keep both files in the restricted host
secret directory and readable by the container user. Start the worker using
the runtime evidence overlay in the same project. If you use the shared
infrastructure overlay, list it before compose.runtime-evidence.yml.
docker compose -f compose.yml -f compose.nats.yml -f compose.runtime-evidence.yml \
up -d --build --wait network-runtime-subscriber-worker
The overlay mounts the two files only in the subscriber. The base development stack still accepts direct credentials for local runs.
Verify a pilot receipt¶
Use an operator's read-only database connection and set the runtime_event_id
psql variable to the collector receipt's event ID. Check that the returned
artifact hash and observation ID match the receipt, that publish_status
is published, and that materialized is true before testing a scan.
select e.event_id, e.publish_status, e.artifact_hash,
a.canonical_json->>'observation_id' as observation_id,
o.runtime_observation_id is not null as materialized,
o.provider_response_status, o.verdict, o.observed_at, o.expires_at
from qr_trust.event_outbox e
join qr_trust.published_artifacts a
on a.artifact_id = e.artifact_id and a.artifact_hash = e.artifact_hash
left join qr_trust.runtime_observations o
on o.source_artifact_hash = e.artifact_hash
where e.event_id = :'runtime_event_id'
and e.event_type = 'runtime.verdict.observed';
With a fresh verifier cache and a current clear observation, record the scanner decision ID. Pause collection for that pilot destination and repeat the scan once the observation expires. The scanner should return runtime unavailable while retaining the verified issuer and destination binding. Refresh evidence and record the resulting decision. Keep the receipt and decision IDs in the operator's private evidence packet.
Deployment Gates¶
Before live provider traffic is enabled, operators should verify:
npm run runtime-safety:smoke- scanner-decision examples for green, orange-unavailable, orange-risky, and red-blocked outcomes
- runtime-safety observation examples for clear, risky, blocked, and unavailable provider verdicts
- bounded provider timeout behavior
- no raw QR payloads or user identifiers are sent unless explicitly required
make check-network-contracts
Provider credentials, rate-limit policies, regional routing, audit exports, and vendor-specific safe-browsing or reputation contracts remain deployment work.