feat: add generic Unix-socket secrets provider#165
Conversation
Greptile SummaryThis PR adds a
Confidence Score: 5/5The PR is safe to merge. The socket provider implementation is carefully bounded: one connection per lookup, a single monotonic deadline, zeroizing storage throughout, and fail-closed on every validation failure. The three concerns raised in prior review threads — missing Protocol scope is now serialized in src/stdlib/secrets/socket.rs — the Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant ntnt as ntnt runtime
participant sg as secrets.rs (ProviderGroup)
participant sp as SocketSecretProvider
participant fs as Filesystem checks
participant agent as Local secrets agent (Unix socket)
ntnt->>sg: lookup_secret("API_KEY")
sg->>sg: validate_secret_name, enforce_declared
sg->>sg: configured_provider_group_from_values()
sg->>fs: validate_existing_socket_path, validate_no_symlink_components (production)
sg->>sp: SocketSecretProvider::new[_with_trusted_root]
loop Up to 2 attempts per endpoint, failover on Unavailable only
sp->>fs: symlink_metadata (re-validate at connect time)
sp->>agent: connect (deadline-bounded)
sp->>agent: "{protocol,request_id,op,name,scope} + newline"
sp->>agent: shutdown(Write) half-close
agent-->>sp: "{protocol,request_id,status,scope,value} + newline"
sp->>sp: nonblocking read — reject any trailing byte
sp->>sp: validate protocol, request_id, scope, frame size, value size
sp-->>sg: "ProviderLookup::Found(Zeroizing<String>)"
end
sg->>sg: SecretValue::new_zeroizing (no plaintext copy)
sg-->>ntnt: Some(SecretValue [REDACTED])
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant ntnt as ntnt runtime
participant sg as secrets.rs (ProviderGroup)
participant sp as SocketSecretProvider
participant fs as Filesystem checks
participant agent as Local secrets agent (Unix socket)
ntnt->>sg: lookup_secret("API_KEY")
sg->>sg: validate_secret_name, enforce_declared
sg->>sg: configured_provider_group_from_values()
sg->>fs: validate_existing_socket_path, validate_no_symlink_components (production)
sg->>sp: SocketSecretProvider::new[_with_trusted_root]
loop Up to 2 attempts per endpoint, failover on Unavailable only
sp->>fs: symlink_metadata (re-validate at connect time)
sp->>agent: connect (deadline-bounded)
sp->>agent: "{protocol,request_id,op,name,scope} + newline"
sp->>agent: shutdown(Write) half-close
agent-->>sp: "{protocol,request_id,status,scope,value} + newline"
sp->>sp: nonblocking read — reject any trailing byte
sp->>sp: validate protocol, request_id, scope, frame size, value size
sp-->>sg: "ProviderLookup::Found(Zeroizing<String>)"
end
sg->>sg: SecretValue::new_zeroizing (no plaintext copy)
sg-->>ntnt: Some(SecretValue [REDACTED])
Reviews (3): Last reviewed commit: "fix: complete socket responses at newlin..." | Re-trigger Greptile |
Summary
unix-socketproduction provider forstd/secretsLanguage boundary
This PR does not add a Larri provider, Infisical dependency, or application-specific behavior. The public selector is
NTNT_SECRETS_PROVIDER=unix-socket, the production trust root is/run/ntnt-secrets, and the protocol documentation describes a generic local agent.It also does not expose a general socket API to ntnt programs. Unix domain sockets are an internal transport for the secrets-provider contract, where filesystem ownership and permissions authenticate a same-host endpoint. WebSockets are a separate remote, long-lived duplex networking feature and are not needed for bounded local secret lookup.
Protocol:
docs/secrets-agent-protocol.mdSecurity properties
/run/ntnt-secretsunavailableretries or fails overVerification
cargo test --all-targetscargo build --profile dev-releasecargo fmt --all -- --checkdocs --validatePlatform note
The provider is Unix-only and fails closed on other targets. Linux tests pass locally; native CI is authoritative for macOS and Windows behavior.