GeezerVison is showing github.com — Preserve scoped stream authorization-loss audit causes · PastureStack/host-api@ba4c09c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/security-release-gate.yml +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | runs-on: ubuntu-24.04 | 17 | 17 | timeout-minutes: 120 | 18 | 18 | env: | 19 | | - CANDIDATE_VERSION: 0.38.6 | | 19 | + CANDIDATE_VERSION: 0.38.7 | 20 | 20 | DAPPER_IMAGE: pasturestack-host-api-dapper:security-gate | 21 | 21 | TRIVY_IMAGE: ghcr.io/aquasecurity/trivy:0.73.0@sha256:7cced7cae583819fc7806d4cbc0dbbc7cad18b99f7d3e235192e6da8c091045c | 22 | 22 | COSIGN_IMAGE: ghcr.io/sigstore/cosign/cosign:v3.1.3@sha256:9e5c2f2edc34351160407ca3416c61855bdf9403c3c5936e0f0be7fc261611b8 | | 36 | 36 | test -z "$(git status --porcelain)" | 37 | 37 | test "$(git rev-parse HEAD)" = "$GITHUB_SHA" | 38 | 38 | # Exactly one reviewed maintenance commit after the existing published main. | 39 | | - test "$(git rev-list --count b124a9cce56cc3e1082d2f72434592bccb15f6ef..HEAD)" = 1 | 40 | | - test "$(git rev-list --count --merges b124a9cce56cc3e1082d2f72434592bccb15f6ef..HEAD)" = 0 | | 39 | + test "$(git rev-list --count 67d1e58d1999730f106ba76c3ee3cf03bbf495d6..HEAD)" = 1 | | 40 | + test "$(git rev-list --count --merges 67d1e58d1999730f106ba76c3ee3cf03bbf495d6..HEAD)" = 0 | 41 | 41 | private_pattern=$(printf '%s|%s|%s' 'chen''21019' '10\.0\.0\.''125' 'C:\\''Users\\') | 42 | 42 | if git grep -n -E "$private_pattern" -- .; then | 43 | 43 | echo 'Private operator data is present in the public source tree.' >&2 | |
Collapse file Copy file name to clipboardExpand all lines: COMPATIBILITY.md +3-1Lines changed: 3 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,9 @@ Preferred settings use `platform-*` names. Historical `cattle-*` flags, legacy D | 6 | 6 |
| 7 | 7 | Operator lifecycle messages support `en-US` and `zh-TW`. HTTP response bodies, log streams, statistics payloads, Docker output, identifiers, and protocol errors are not translated. | 8 | 8 |
| 9 | | -The source package version is `0.38.6`, built with Go 1.27.3 on a digest-pinned Ubuntu 26.04 image, a frozen bootstrap package snapshot, and checksum-pinned official security fixes. The final builder inventory records installed versions separately from the bootstrap lock. A published package must retain its reviewed producer revision, byte-identical packaging evidence, and successful security checks of the unpacked binary. Server packaging consumes `host-api-0.38.6.tar.gz`; its filename, executable layout, architecture, legacy SHA-1 compatibility files, and SHA-256 integrity files are release contracts. Product versions must remain pure numeric `MAJOR.MINOR.PATCH` values without branding or maintenance suffixes. | | 9 | +The source package version is `0.38.7`, built with Go 1.27.3 on a digest-pinned Ubuntu 26.04 image, a frozen bootstrap package snapshot, and checksum-pinned official security fixes. The final builder inventory records installed versions separately from the bootstrap lock. A published package must retain its reviewed producer revision, byte-identical packaging evidence, and successful security checks of the unpacked binary. Server packaging consumes `host-api-0.38.7.tar.gz`; its filename, executable layout, architecture, legacy SHA-1 compatibility files, and SHA-256 integrity files are release contracts. Product versions must remain pure numeric `MAJOR.MINOR.PATCH` values without branding or maintenance suffixes. | | 10 | + | | 11 | +The `key-audit-v1,key-delegation-v1` backend protocol and endpoint contracts remain unchanged. All non-allowed introspection results still close scoped streams. Confirmed authorization-loss evidence requires either expiry of the previously verified signed grant, or a configured-Engine 401/403 response carrying an allowlisted stable authorization code. Network failures, redirects, outages, malformed or mismatched responses are unknown, never confirmed revocation. Only authorized scoped transport cancellations receive a final recheck, inside the existing seven-second total report budget and without holding the audit mutex. A confirmed denial outranks a later disconnect or cancellation-induced Docker error; a completed success or genuine backend failure and the frozen first terminal record cannot be overwritten. Ordinary JWTs, Full/legacy traces, handshake admission, durable retry and ticket-bound agent/target/Host identities retain their contracts. No publication or native PASS is implied by the source version. | 10 | 12 |
| 11 | 13 | Before release, validate token acquisition, event forwarding, logs, stats, exec, console, Docker socket proxy, container proxy, disabled-proxy behavior, key parsing, and restart behavior. | 12 | 14 |
| |
Collapse file Copy file name to clipboardExpand all lines: README.md +3-1Lines changed: 3 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,12 +6,14 @@ PastureStack is an independent community effort to preserve, audit, and moderniz | 6 | 6 |
| 7 | 7 | ## Capabilities | 8 | 8 |
| 9 | | -The source package version is `0.38.6`, built with Go 1.27.3. Use a published release only after its source, reproducibility, vulnerability, and packaged-binary checks pass; a source version is not publication evidence. Target-bound API Key tickets require matching Engine introspection at handshake and during logs, exec, and statistics streams. Revocation or expiry closes the stream; it does not stop its container or kill an already started exec process. Legacy and full-without-expiry tokens retain their authentication contract. | | 9 | +The source package version is `0.38.7`, built with Go 1.27.3. Use a published release only after its source, reproducibility, vulnerability, and packaged-binary checks pass; a source version is not publication evidence. Target-bound API Key tickets require matching Engine introspection at handshake and during logs, exec, and statistics streams. Revocation or expiry closes the stream; it does not stop its container or kill an already started exec process. Legacy and full-without-expiry tokens retain their authentication contract. | 10 | 10 |
| 11 | 11 | The authenticated backend connection declares the exact `key-audit-v1,key-delegation-v1` capabilities. A compatible Proxy requires that declaration for every verified API Key stream, including full keys, so an older embedded backend cannot bypass terminal audit. Ordinary non-Key streams retain their existing backend compatibility. | 12 | 12 |
| 13 | 13 | Terminal evidence is sent with the host agent's credential. A private persistent spool reserves a PENDING record before execution for every verified API Key trace, preserves the first terminal result, and retries only evidence after outages or process restarts. Interrupted PENDING streams become `CANCELLED`, never a fabricated success. Original API Key and agent secrets are not persisted. Full keys retain their permission payload and expiry contract, but do not bypass audit durability; unavailable admission closes with retryable `AuditUnavailable` (503 semantics), not a permission denial. Ordinary non-Key tokens have no new audit-admission requirement. | 14 | 14 |
| | 15 | +For an authorized scoped stream, terminal classification preserves confirmed authorization loss even when a later transport close arrives. A transport cancellation receives one bounded recheck of the original signed grant before the terminal record is frozen; an unavailable or unverifiable check remains `StreamCancelled`, not confirmed revocation. This records authorization at finalization, not proof of which peer first closed the connection. Completed EOF or backend failures, ordinary JWTs and Full/legacy permission contracts are unchanged. | | 16 | + | 15 | 17 | ## Configuration | 16 | 18 |
| 17 | 19 | Preferred flags are `--platform-url`, `--platform-access-key`, and `--platform-secret-key`. Existing `--cattle-*` flags remain compatibility aliases. Set `PASTURESTACK_HOME` for the state root and `PASTURESTACK_LOCALE=en-US` or `zh-TW` for operator messages. `host-api --version` reports the pure numeric `MAJOR.MINOR.PATCH` build version. | |
Collapse file Copy file name to clipboardExpand all lines: auth/delegation.go +25-4Lines changed: 25 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,6 +37,27 @@ func verifyDelegation(raw, path string, token *jwt.Token) (*jwt.Token, bool) { | 37 | 37 |
| 38 | 38 | // The original signed token, not normalized claims, is rechecked for every tick. | 39 | 39 | func StartStreamWatch(parent context.Context, raw string, verified *jwt.Token, deny func()) context.CancelFunc { | | 40 | + return startStreamWatchResult(parent, raw, verified, func(delegation.Result) { deny() }) | | 41 | +} | | 42 | + | | 43 | +// Watch closes immediately on either a confirmed denial or an unknown check. | | 44 | +// Only the former may become AuthorizationRevoked terminal evidence. | | 45 | +func (a *StreamAudit) Watch(parent context.Context, raw string, verified *jwt.Token, deny func()) context.CancelFunc { | | 46 | + return startStreamWatchResult(parent, raw, verified, func(result delegation.Result) { | | 47 | + a.authorizationResult(result) | | 48 | + deny() | | 49 | + }) | | 50 | +} | | 51 | + | | 52 | +func (a *StreamAudit) authorizationResult(result delegation.Result) { | | 53 | + if result == delegation.ConfirmedDenied { | | 54 | + a.Cancel("AuthorizationRevoked") | | 55 | + } else if result != delegation.Allowed { | | 56 | + a.Cancel("StreamCancelled") | | 57 | + } | | 58 | +} | | 59 | + | | 60 | +func startStreamWatchResult(parent context.Context, raw string, verified *jwt.Token, deny func(delegation.Result)) context.CancelFunc { | 40 | 61 | initial, ok := MapClaims(verified) | 41 | 62 | if ok { | 42 | 63 | if _, scoped := initial[delegation.Claim]; !scoped { | @@ -45,18 +66,18 @@ func StartStreamWatch(parent context.Context, raw string, verified *jwt.Token, d | 45 | 66 | } | 46 | 67 | token, err := ParseToken(raw, config.Config.ParsedPublicKey) | 47 | 68 | if err != nil { | 48 | | - deny() | | 69 | + deny(delegation.Unknown) | 49 | 70 | return func() {} | 50 | 71 | } | 51 | 72 | claims, ok := MapClaims(token) | 52 | 73 | if !ok { | 53 | | - deny() | | 74 | + deny(delegation.Unknown) | 54 | 75 | return func() {} | 55 | 76 | } | 56 | 77 | grant, err := delegation.Parse(map[string]interface{}(claims)) | 57 | 78 | if err != nil { | 58 | | - deny() | | 79 | + deny(delegation.Unknown) | 59 | 80 | return func() {} | 60 | 81 | } | 61 | | - return delegation.New(config.Config.PlatformURL).Watch(parent, raw, grant, deny) | | 82 | + return delegation.New(config.Config.PlatformURL).WatchResult(parent, raw, grant, deny) | 62 | 83 | } |
Collapse file Copy file name to clipboardExpand all lines: auth/stream_audit.go +68-16Lines changed: 68 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,6 +22,9 @@ import ( | 22 | 22 | type StreamAudit struct { | 23 | 23 | mu sync.Mutex | 24 | 24 | enabled, required, cancelled bool | | 25 | + authorized, completed, frozen bool | | 26 | + reportOnce sync.Once | | 27 | + recheck func(context.Context) delegation.Result | 25 | 28 | token, endpoint, accessKey, secretKey string | 26 | 29 | outcome, failureCode string | 27 | 30 | client *http.Client | @@ -68,6 +71,12 @@ func BeginStreamAudit(raw string) *StreamAudit { | 68 | 71 | return a | 69 | 72 | } | 70 | 73 | } | | 74 | + if a.required && a.enabled { | | 75 | + if grant, err := delegation.Parse(map[string]interface{}(claims)); err == nil && grant != nil { | | 76 | + verifier := delegation.New(config.Config.PlatformURL) | | 77 | + a.recheck = func(ctx context.Context) delegation.Result { return verifier.CheckResult(ctx, raw, grant) } | | 78 | + } | | 79 | + } | 71 | 80 | if envelope, ok := claims["apiKeyAudit"].(map[string]interface{}); ok { | 72 | 81 | a.expiresAt = receiptExpiry(envelope) | 73 | 82 | } | @@ -103,51 +112,94 @@ func (a *StreamAudit) Ready() bool { | 103 | 112 | func (a *StreamAudit) Enabled() bool { return a.enabled } | 104 | 113 | func (a *StreamAudit) Authorized() { | 105 | 114 | a.mu.Lock() | | 115 | + defer a.mu.Unlock() | | 116 | + if a.frozen || a.completed || a.cancelled { | | 117 | + return | | 118 | + } | | 119 | + a.authorized = true | 106 | 120 | a.outcome = "CANCELLED" | 107 | 121 | a.failureCode = "ClientDisconnected" | 108 | | - a.mu.Unlock() | 109 | 122 | } | 110 | 123 | func (a *StreamAudit) Succeed() { | 111 | 124 | a.mu.Lock() | 112 | 125 | defer a.mu.Unlock() | 113 | | - if !a.cancelled { | | 126 | + if !a.cancelled && !a.frozen && !a.completed { | 114 | 127 | a.outcome = "SUCCEEDED" | 115 | 128 | a.failureCode = "" | | 129 | + a.completed = true | 116 | 130 | } | 117 | 131 | } | 118 | 132 | func (a *StreamAudit) Fail(code string) { | 119 | 133 | a.mu.Lock() | 120 | 134 | defer a.mu.Unlock() | 121 | | - if !a.cancelled { | | 135 | + if !a.cancelled && !a.frozen && !a.completed { | 122 | 136 | a.outcome = "FAILED" | 123 | 137 | a.failureCode = code | | 138 | + a.completed = true | 124 | 139 | } | 125 | 140 | } | 126 | 141 | func (a *StreamAudit) Cancel(code string) { | 127 | 142 | a.mu.Lock() | 128 | 143 | defer a.mu.Unlock() | | 144 | + if a.frozen || a.completed || (a.cancelled && cancellationPriority(code) <= cancellationPriority(a.failureCode)) { | | 145 | + return | | 146 | + } | 129 | 147 | a.cancelled = true | 130 | 148 | a.outcome = "CANCELLED" | 131 | 149 | a.failureCode = code | 132 | 150 | } | 133 | 151 |
| 134 | | -func (a *StreamAudit) Report() { | 135 | | - if !a.enabled { | 136 | | - return | | 152 | +func cancellationPriority(code string) int { | | 153 | + switch code { | | 154 | + case "AuthorizationRevoked": | | 155 | + return 3 | | 156 | + case "StreamCancelled": | | 157 | + return 2 | | 158 | + default: | | 159 | + return 1 | 137 | 160 | } | 138 | | - queue := a.queue | 139 | | - if queue == nil { | 140 | | - queue, _ = configuredCompletionSpool() | | 161 | +} | | 162 | + | | 163 | +func (a *StreamAudit) finalize(ctx context.Context) { | | 164 | + a.mu.Lock() | | 165 | + check := a.recheck | | 166 | + transport := a.required && a.authorized && !a.completed && !a.frozen && | | 167 | + a.outcome == "CANCELLED" && a.failureCode != "AuthorizationRevoked" | | 168 | + a.mu.Unlock() | | 169 | + if transport { | | 170 | + result := delegation.Unknown | | 171 | + if check != nil { | | 172 | + result = check(ctx) // Never hold the audit mutex during network I/O. | | 173 | + } | | 174 | + a.authorizationResult(result) | 141 | 175 | } | 142 | | - if queue == nil || queue.complete(a.record("TERMINAL")) != nil { | 143 | | - glog.Warning("API key stream terminal evidence could not be persisted") | | 176 | + a.mu.Lock() | | 177 | + a.frozen = true | | 178 | + a.mu.Unlock() | | 179 | +} | | 180 | + | | 181 | +func (a *StreamAudit) Report() { | | 182 | + if !a.enabled { | 144 | 183 | return | 145 | 184 | } | 146 | | - ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second) | 147 | | - defer cancel() | 148 | | - if !queue.deliverOne(ctx, completionID(a.token)) { | 149 | | - glog.Warning("API key stream terminal audit remains pending delivery") | 150 | | - } | | 185 | + a.reportOnce.Do(func() { | | 186 | + // Rechecking and delivery share the existing total report budget. The | | 187 | + // stream is already closed; this cannot renew or reopen its authority. | | 188 | + ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second) | | 189 | + defer cancel() | | 190 | + a.finalize(ctx) | | 191 | + queue := a.queue | | 192 | + if queue == nil { | | 193 | + queue, _ = configuredCompletionSpool() | | 194 | + } | | 195 | + if queue == nil || queue.complete(a.record("TERMINAL")) != nil { | | 196 | + glog.Warning("API key stream terminal evidence could not be persisted") | | 197 | + return | | 198 | + } | | 199 | + if !queue.deliverOne(ctx, completionID(a.token)) { | | 200 | + glog.Warning("API key stream terminal audit remains pending delivery") | | 201 | + } | | 202 | + }) | 151 | 203 | } | 152 | 204 |
| 153 | 205 | func (a *StreamAudit) deliver(ctx context.Context) bool { | |
|