GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Preserve scoped stream authorization-loss audit causes · PastureStack/host-api@ba4c09c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • security-release-gate.yml
  • COMPATIBILITY.md
  • README.md
  • auth
    • delegation.go
    • stream_audit.go
    • stream_cause_test.go
  • delegation
    • classified_test.go
    • delegation.go
  • exec
    • exec.go
  • logs
    • logs.go
    • scoped_logs_integration_test.go
  • main.go
  • main_test.go
  • scripts
    • build
    • package
    • test
  • stats
    • container_stats.go
    • host_stats.go
    • stats.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/security-release-gate.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/security-release-gate.yml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-24.04
1717
timeout-minutes: 120
1818
env:
19-
CANDIDATE_VERSION: 0.38.6
19+
CANDIDATE_VERSION: 0.38.7
2020
DAPPER_IMAGE: pasturestack-host-api-dapper:security-gate
2121
TRIVY_IMAGE: ghcr.io/aquasecurity/trivy:0.73.0@sha256:7cced7cae583819fc7806d4cbc0dbbc7cad18b99f7d3e235192e6da8c091045c
2222
COSIGN_IMAGE: ghcr.io/sigstore/cosign/cosign:v3.1.3@sha256:9e5c2f2edc34351160407ca3416c61855bdf9403c3c5936e0f0be7fc261611b8
@@ -36,8 +36,8 @@ jobs:
3636
test -z "$(git status --porcelain)"
3737
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
3838
# 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
4141
private_pattern=$(printf '%s|%s|%s' 'chen''21019' '10\.0\.0\.''125' 'C:\\''Users\\')
4242
if git grep -n -E "$private_pattern" -- .; then
4343
echo 'Private operator data is present in the public source tree.' >&2
Collapse file

‎COMPATIBILITY.md‎

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 numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Preferred settings use `platform-*` names. Historical `cattle-*` flags, legacy D
66

77
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.
88

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.
1012

1113
Before release, validate token acquisition, event forwarding, logs, stats, exec, console, Docker socket proxy, container proxy, disabled-proxy behavior, key parsing, and restart behavior.
1214

Collapse file

‎README.md‎

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 numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ PastureStack is an independent community effort to preserve, audit, and moderniz
66

77
## Capabilities
88

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.
1010

1111
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.
1212

1313
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.
1414

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+
1517
## Configuration
1618

1719
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

‎auth/delegation.go‎

Copy file name to clipboardExpand all lines: auth/delegation.go
+25-4Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ func verifyDelegation(raw, path string, token *jwt.Token) (*jwt.Token, bool) {
3737

3838
// The original signed token, not normalized claims, is rechecked for every tick.
3939
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 {
4061
initial, ok := MapClaims(verified)
4162
if ok {
4263
if _, scoped := initial[delegation.Claim]; !scoped {
@@ -45,18 +66,18 @@ func StartStreamWatch(parent context.Context, raw string, verified *jwt.Token, d
4566
}
4667
token, err := ParseToken(raw, config.Config.ParsedPublicKey)
4768
if err != nil {
48-
deny()
69+
deny(delegation.Unknown)
4970
return func() {}
5071
}
5172
claims, ok := MapClaims(token)
5273
if !ok {
53-
deny()
74+
deny(delegation.Unknown)
5475
return func() {}
5576
}
5677
grant, err := delegation.Parse(map[string]interface{}(claims))
5778
if err != nil {
58-
deny()
79+
deny(delegation.Unknown)
5980
return func() {}
6081
}
61-
return delegation.New(config.Config.PlatformURL).Watch(parent, raw, grant, deny)
82+
return delegation.New(config.Config.PlatformURL).WatchResult(parent, raw, grant, deny)
6283
}
Collapse file

‎auth/stream_audit.go‎

Copy file name to clipboardExpand all lines: auth/stream_audit.go
+68-16Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
type StreamAudit struct {
2323
mu sync.Mutex
2424
enabled, required, cancelled bool
25+
authorized, completed, frozen bool
26+
reportOnce sync.Once
27+
recheck func(context.Context) delegation.Result
2528
token, endpoint, accessKey, secretKey string
2629
outcome, failureCode string
2730
client *http.Client
@@ -68,6 +71,12 @@ func BeginStreamAudit(raw string) *StreamAudit {
6871
return a
6972
}
7073
}
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+
}
7180
if envelope, ok := claims["apiKeyAudit"].(map[string]interface{}); ok {
7281
a.expiresAt = receiptExpiry(envelope)
7382
}
@@ -103,51 +112,94 @@ func (a *StreamAudit) Ready() bool {
103112
func (a *StreamAudit) Enabled() bool { return a.enabled }
104113
func (a *StreamAudit) Authorized() {
105114
a.mu.Lock()
115+
defer a.mu.Unlock()
116+
if a.frozen || a.completed || a.cancelled {
117+
return
118+
}
119+
a.authorized = true
106120
a.outcome = "CANCELLED"
107121
a.failureCode = "ClientDisconnected"
108-
a.mu.Unlock()
109122
}
110123
func (a *StreamAudit) Succeed() {
111124
a.mu.Lock()
112125
defer a.mu.Unlock()
113-
if !a.cancelled {
126+
if !a.cancelled && !a.frozen && !a.completed {
114127
a.outcome = "SUCCEEDED"
115128
a.failureCode = ""
129+
a.completed = true
116130
}
117131
}
118132
func (a *StreamAudit) Fail(code string) {
119133
a.mu.Lock()
120134
defer a.mu.Unlock()
121-
if !a.cancelled {
135+
if !a.cancelled && !a.frozen && !a.completed {
122136
a.outcome = "FAILED"
123137
a.failureCode = code
138+
a.completed = true
124139
}
125140
}
126141
func (a *StreamAudit) Cancel(code string) {
127142
a.mu.Lock()
128143
defer a.mu.Unlock()
144+
if a.frozen || a.completed || (a.cancelled && cancellationPriority(code) <= cancellationPriority(a.failureCode)) {
145+
return
146+
}
129147
a.cancelled = true
130148
a.outcome = "CANCELLED"
131149
a.failureCode = code
132150
}
133151

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
137160
}
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)
141175
}
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 {
144183
return
145184
}
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+
})
151203
}
152204

153205
func (a *StreamAudit) deliver(ctx context.Context) bool {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.