Skip to content

fix(model): harden redirects, uploads, hidden files, plain-http API URLs and response sizes (STO-1324) - #406

Open
jebenexer wants to merge 33 commits into
benjaminbrannaka/sto-1236-redact-symlinksfrom
benjaminbrannaka/sto-1324-redirects-exit-codes
Open

jebenexer wants to merge 33 commits into
benjaminbrannaka/sto-1236-redact-symlinksfrom
benjaminbrannaka/sto-1324-redirects-exit-codes

Conversation

@jebenexer

@jebenexer jebenexer commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

STO-1324: runpodctl API-key forwarding and upload hardening

Stacked on #405 (STO-1236). The diff against that branch is the STO-1324 change only (26 files, +1226/-39).

  • Resolves STO-1324 (security, Model Repository threat model).
  • GraphQL and upload requests no longer follow redirects, so the API key is not forwarded to another host.
  • Upload URLs are validated; a failed or short upload now returns an error and a non-zero exit code (it used to exit 0).
  • model add skips .git/ and .env* under --model-path by default. New flag --include-hidden restores the old behavior.
  • Plain http:// API URLs are refused unless the host is loopback, or --insecure / RUNPOD_ALLOW_INSECURE_API=1 is set. This also applies to the REST client and RUNPOD_API_URL, not only GraphQL.
  • Every API response read is capped at 32 MiB (internal/api/bodylimit.go).
  • New: internal/configenv/insecure.go, flag registration in cmd/root.go, one README line.

Behavior changes for users: new flags --include-hidden and --insecure; env var RUNPOD_ALLOW_INSECURE_API=1; non-zero exit on failed uploads; hidden files skipped by default; responses over 32 MiB fail.

Every client that sends the API key refuses redirects: GraphQL, REST, REST v2, invoke and logs. Model upload URLs are never followed on redirect, and plain-http upload URLs are refused unless --insecure / RUNPOD_ALLOW_INSECURE_API=1 is set or the GraphQL API URL itself is loopback; a loopback upload URL alone does not exempt the check (the stricter behavior is intentional). Failed uploads, FAILED completions, short reads and null parts exit non-zero. API response reads are capped at 32 MiB, REST and invoke included. A non-loopback http:// API URL is refused unless --insecure or RUNPOD_ALLOW_INSECURE_API=1 is set. .git/ and .env* are skipped under --model-path unless --include-hidden is passed. Stacked on #405 (head now includes the signed merge f674bed of the STO-1236 branch).

Test plan:

  • go test ./...
  • go vet ./... and lint (0 new findings)
  • smoke test of the new flags
  • go test -tags e2e ./e2e (not run)
    Not run: go test -tags e2e ./e2e (e2e/ has no model-upload tests). Replaced by a live run of the built binary against a local RunPod-in-a-box stack (GraphQL/REST on :4000, LocalStack S3, a fresh key minted through createApiKeyNew): hidden-file exclusion (9 sensitive entries skipped incl. alias symlinks to .env and .git/config; --include-hidden uploads all 13), insecure-URL refusal (exit 1 before any connection; --insecure and loopback pass), a file truncated mid-run exits 1 with a size-changed error, and a huge error body (loopback fake server, ~8 MB JSON in three shapes) is cut to ~4 KiB with presigned URLs reduced to scheme://host/path. Details are in the reply on the review thread. A second live run covers the token masking (1,507 CLI runs against a localhost fake server with a throwaway key: 0 leaks).

Note: go test -race ./cmd/... reports a data race in cmd/transfer (third-party croc logger). It fails the same way on main and this change does not touch that package.


Note

High Risk
Touches authentication (API key on wire, redirect handling), model upload paths that can leak secrets, and changes default upload behavior—security-critical with user-visible breaking changes.

Overview
Hardens runpodctl around API keys, GraphQL/REST traffic, and model add uploads—addressing STO-1324’s threat model.

API transport: GraphQL (Query) and REST/log clients now refuse non-loopback http:// URLs unless --insecure or RUNPOD_ALLOW_INSECURE_API=1 (internal/configenv, global flag in cmd/root.go). GraphQL does not follow redirects (avoids replaying the bearer token). All API response reads use a 32 MiB cap via ReadBounded / ReadBoundedResponse.

Model uploads: Presigned part/complete URLs must be HTTPS: plain-http upload URLs are refused unless --insecure / RUNPOD_ALLOW_INSECURE_API=1 is set or the GraphQL API URL itself is loopback; a loopback upload URL alone does not exempt the check (the stricter behavior is intentional). Upload HTTP client stops on redirects; server FAILED session status and truncated files after scan fail the command (non-zero exit). Directory scan skips .git/ and .env* by default with new --include-hidden; paths with control chars or backslashes are rejected.

Docs: README documents RUNPOD_ALLOW_INSECURE_API. Broad unit tests cover insecure URLs, redirects, oversize bodies, hidden files, and upload edge cases.

Reviewed by Cursor Bugbot for commit 0a039ae. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0a039ae. Configure here.

Comment thread internal/api/graphql.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread api/graphql_response.go Resolved
Comment thread cmd/model/add_model_to_repo.go Resolved
Comment thread cmd/model/add_model_to_repo.go Resolved
Comment thread api/endpoint.go Resolved
@justinwlin

justinwlin commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Kimi review posted: #406 (review)

How to ask for a Kimi review: GitHub: request @justinwlin as a reviewer, or comment @justinwlin watcher, review on the PR. Slack: DM @justin.lin Watcher, review <PR link>. New commits get an automatic re-review (checked every 5 min). Stop it: DM Watcher, stop <PR link>.

@justinwlin justinwlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimi review, round 1

Verdict: Needs changes. 0 Critical, 2 High, 5 Medium+Low → not approved: 2 High findings.

Context: This stacked PR hardens API-key transport and model uploads, adds sensitive-file exclusion and HTTP opt-ins, and bounds API responses and error excerpts.

Next step: @jebenexer fixes findings 1–7, runs the required live e2e validation, then re-requests review.

Findings

  1. High: A symlink with a benign name bypasses sensitive-target exclusion and uploads .env or .git contents. cmd/model/add_model_to_repo.go:629.
  2. High: Shrinking a file after its upload plan is created but before it opens can produce a successful truncated upload. cmd/model/add_model_to_repo.go:1821.
  3. Medium: Structured REST/GraphQL messages bypass the new 4 KiB redacting error excerpt. internal/api/client.go:459.
  4. Medium: A refused redirect makes followed log streams reconnect indefinitely instead of returning the error. internal/api/logs.go:312.
  5. Medium: The repository-mandated live CLI e2e validation remains unchecked and no replacement e2e coverage is included. cmd/model/model_upload_hardening_test.go:28.
  6. Low: Generated command reference docs omit both new flags. cmd/root.go:147.
  7. Low: The redaction test’s signature begins beyond the excerpt boundary, so the intended straddling case is not exercised. api/error_excerpt_test.go:90.

Questions

  • Which accompanying change updates the external runpodctl skill for --include-hidden, --insecure, and the new upload/filter behavior, as required by AGENTS.md:65?
Other reviewers, PR description, nits
  • @cursor on internal/api/graphql.go:70: Already addressed at 2460019; redirect refusal is present and tested. #406 (comment)
  • @deanq on internal/api/client.go:182: Already addressed at 2460019; REST, REST v2, invoke, and logs all refuse redirects. #406 (comment)
  • @deanq on api/graphql_response.go:94: Already addressed at 96d5ef9; the shared 32 MiB bounded read is now used. #406 (comment)
  • @deanq on cmd/model/add_model_to_repo.go:1652: Already addressed at 09814ce; completion and every part URL are validated before upload. #406 (comment)
  • @deanq on cmd/model/add_model_to_repo.go:553: Already addressed at ef0d66a; the requested names are filtered case-insensitively. #406 (comment)
  • @deanq on api/endpoint.go:208: Already addressed at f7178dd; raw response-body excerpts are bounded and redacted. #406 (comment)
  • PR body claim “26 files, +1226/-39”: stale; the current PR metadata reports 33 files, +1751/-97.
  • Nit cmd/model/add_model_to_repo.go:1719: use lowercase minio to match the output convention.

Kimi (moonshotai/Kimi-K3.1-Pro) · round 1 · 5 review agents (API transport, model upload, tests/conventions, existing feedback, duplication) · 34 min · automated review, a human owns the final call. New commits are checked every 5 min and get an automatic re-review of the changes since this round. Ask for a review: request @justinwlin as a reviewer, comment @justinwlin watcher, review on the PR, or Slack DM @justin.lin Watcher, review https://github.com/runpod/runpodctl/pull/406. Stop re-reviews: Slack DM Watcher, stop https://github.com/runpod/runpodctl/pull/406.

Comment thread cmd/model/add_model_to_repo.go Resolved
Comment thread cmd/model/add_model_to_repo.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread internal/api/logs.go Resolved
return path
}

func TestValidateModelUploadURL(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: AGENTS.md:64 requires every CLI change to be exercised against the live API before completion, while the PR test plan explicitly leaves go test -tags e2e ./e2e unchecked. Run the built binary through the changed hidden-file, insecure-URL, and failed-upload paths, with immediate resource cleanup, before re-review.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exercised live against a local RunPod-in-a-box stack (GraphQL/REST on :4000, LocalStack S3, a fresh RW key minted through createApiKeyNew), with the binary built from 27c4694 (8def476 adds only lint fixes). Hidden files: model add uploaded only .gitattributes, config.json and weights.bin, and skipped 9 sensitive entries (.env, .ENV, .envrc, .git/, a .git gitfile, .netrc, .git-credentials, and the aliases alias-env -> .env and cfg -> .git/config), printing a count only; S3 and the server's file rows matched. --include-hidden uploaded all 13. Insecure URL: http://example.com is refused with exit 1 before any connection (verified with strace); --insecure / RUNPOD_ALLOW_INSECURE_API=1 pass the check; loopback works. Failed upload: a file truncated mid-run after the scan exits 1 with 'its size changed since the model directory was scanned (4096 bytes then, 100 now)'. Huge error body: the local stack can't produce a multi-MB error, so this one ran against a loopback fake returning ~8 MB JSON in three shapes; every error was cut to about 4 KiB with '... (truncated)', and presigned URLs, including one straddling the cut, were reduced to scheme://host/path. Everything else ran against the local stack, and nothing was skipped. Test models, S3 objects and the key were cleaned up and revoked. Not covered: the production API itself (this is the local stack).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not addressed at 8def476e: the PR body still leaves go test -tags e2e ./e2e unchecked, and no replacement live CLI evidence was provided. The repository-required hidden-file, insecure-URL, and failed-upload checks remain outstanding.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed: correction to round 2—comment 4637945015 already supplied detailed local RunPod-in-a-box/LocalStack evidence before that review. It explicitly excludes production API coverage, so the required live-API run and cleanup remain outstanding.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not resolving this; it's yours to close. The PR test plan now carries the live-run evidence. To be plain about its scope: every live run was against the local RunPod-in-a-box stack (the RunPod GraphQL/REST app on :4000 with LocalStack S3), plus localhost fake servers for error shapes the stack can't produce. Production was not exercised, so the production API is not covered. Against the local stack with a freshly minted, since-revoked key: hidden files: only non-sensitive files were uploaded, including through alias symlinks to .env and .git/config, and --include-hidden uploaded all of them; insecure URL: an http:// API URL is refused before any connection, and --insecure lets it through; failed upload: a file shrunk mid-run exits 1; symlink and FIFO swaps: 380 swap-race runs and 199 FIFO-swap runs never uploaded an outside file and never hung; cleanup: models, S3 objects and the key were removed after each run.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed: the local RunPod-in-a-box and LocalStack evidence is documented, but your reply explicitly excludes production API coverage. The repository-required built-binary run against the live API, including cleanup, remains outstanding at 5ed4331; leaving this thread open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed remains accurate at 33d2dab0: the documented evidence covers a local RunPod-in-a-box/LocalStack stack, while the repository-required production built-binary validation and cleanup remain outstanding. Leaving this thread open.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be plain about scope: every live run was against the local RunPod-in-a-box stack (GraphQL on :4000, LocalStack S3, a key minted for the run and since revoked, models and objects cleaned up), plus loopback fakes for error shapes the stack cannot produce. The production API itself was not exercised, so production coverage is still outstanding here. The local runs are described in the PR body.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed at 4d6fdc96: the PR test plan still documents only local RunPod-in-a-box/LocalStack and localhost fakes. The repository-required production built-binary run and cleanup remain outstanding, so R1-5 stays partially fixed.

Comment thread cmd/root.go Resolved
Comment thread api/error_excerpt_test.go Resolved

@justinwlin justinwlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimi review, round 2

Verdict: Approved. 0 Critical, 0 High, 5 Medium+Low → approved (approval gate: no Critical/High and fewer than 10 Medium+Low).

Context: This stacked PR hardens authenticated API transports and model uploads against credential leaks, unsafe redirects, malicious files, and oversized responses. This round fixes most round-1 findings, with four Medium issues and one Low documentation mismatch remaining.

Next step: @jebenexer merges; address the five non-blocking findings and the live e2e requirement.

Status of prior findings

# Severity Status Evidence
R1-1 High Fixed at a1938233 Resolved symlink components are checked at cmd/model/add_model_to_repo.go:658-727.
R1-2 High Fixed at a1938233 Scan/open sizes must match at cmd/model/add_model_to_repo.go:1845-1851.
R1-3 Medium Partially fixed at 3e4bca51 cmd/model/remove_model.go:125 still returns a raw GraphQL message.
R1-4 Medium Fixed at 252fbf9d Redirects are permanent at internal/api/logs.go:575-590.
R1-5 Medium Not addressed Live e2e remains unchecked in the PR body.
R1-6 Low Fixed at 27c46944 Generated docs include both new flags.
R1-7 Low Fixed at 3e4bca51, 8def476e The signature-straddling test now crosses the cut.

Findings

  1. Medium (R1-3, partially fixed): The dependency-check GraphQL path still permits oversized, unredacted messages. Existing thread.
  2. Medium (R1-5, not addressed): Required live CLI e2e evidence is still missing. Existing thread.
  3. Medium (R2-1): Refused redirects can disclose signed query credentials through raw Location values. internal/api/client.go:88, :145.
  4. Medium (R2-2): Failed bounded reads erase received HTTP statuses and stable API error codes. internal/api/client.go:201.
  5. Low (R2-3): Two PR-body claims say loopback uploads are exempt, but the intentional policy also requires opt-in or a loopback GraphQL API. cmd/model/add_model_to_repo.go:1797.

Questions

  • Which accompanying change updates the external runpodctl skill for the new flags and behavior? R1-Q1 remains unanswered.
Other reviewers, PR description, nits
  • @deanq’s redirect, GraphQL limit, upload HTTP policy, sensitive-name, and raw-body findings remain addressed at this head: redirects, limit, uploads, names, errors. Human-owned threads were left to their owners.
  • @cursor’s GraphQL redirect finding remains addressed.
  • R1-C1 remains: the PR body says 26 files, +1226/-39; GitHub currently reports 106 files, +2264/-122.
  • Nit cmd/model/add_model_to_repo.go:1789: use lowercase minio to match output conventions.
  • CI at review time: build, fuzz, and all four flake jobs passed; report was skipped. No required checks were configured.
  • Review relied on code inspection and the author’s reported unit/vet/lint results; no builds, tests, codegen, or live e2e were run by this reviewer.

Kimi (moonshotai/Kimi-K3.1-Pro) · round 2 · 4 review agents (existing feedback, model uploads, API transport, tests/docs/conventions) · 15 min · automated review, a human owns the final call. New commits are checked every 5 min and get an automatic re-review of the changes since this round. Ask for a review: request @justinwlin as a reviewer, comment @justinwlin watcher, review on the PR, or Slack DM @justin.lin Watcher, review <PR link>. Stop re-reviews: Slack DM Watcher, stop <PR link>.

Comment thread internal/api/client.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread cmd/model/add_model_to_repo.go Resolved
@jebenexer

Copy link
Copy Markdown
Collaborator Author

@justinwlin Additional hardening beyond the original review threads (62d4d89 merges #405's token masking; 01d33f5, 7de5a18, 7952b83): (1) Redirect refusals: the Location header in a refused-redirect error is masked (redact.Text), then reduced to scheme://host/path (redact.URL), so a signed S3 URL or a token in a redirect target is never printed. (2) Connection errors: errors from the HTTP client in internal/api/client.go, logs.go, graphql.go and api/query.go go through redact.Error instead of printing the full request URL, so a key in the URL's query or userinfo is never shown. Validated live with a throwaway key against a localhost server across pod list, model list, pod logs and pod logs --follow: 1,507 runs, 0 leaks of planted Bearer, rpa_ and configured-key values, signed Locations, or ?api_key= and userinfo URLs. Also passed: full tests, -race, golangci-lint (0 new) and the nix baseline (no new findings). The CLI itself never puts the API key in a URL; it is sent only as Authorization: Bearer.

@jebenexer
jebenexer requested a review from justinwlin November 20, 2026 03:18

@justinwlin justinwlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimi review, round 3

Verdict: Approved. 0 Critical, 0 High, 5 Medium+Low → approved (approval gate: no Critical/High and fewer than 10 Medium+Low).

Context: This stacked PR hardens authenticated API transports and model uploads against credential leaks, unsafe redirects, malicious files, and oversized responses. This push scrubs redirect/transport URLs and masks tokens before truncation, but one redirect credential case and three earlier findings remain open.

Next step: @jebenexer merges; address the five non-blocking findings and complete the required live-API validation and cleanup.

Status of prior findings

# Finding Severity Status Evidence
R1-1 Sensitive symlink targets High Fixed at a1938233 Resolved components remain checked at cmd/model/add_model_to_repo.go:658-727.
R1-2 Truncated upload after scan High Fixed at a1938233 Scan/open sizes must match at cmd/model/add_model_to_repo.go:1845-1851.
R1-3 Raw structured error messages Medium Partially fixed at 3e4bca51 cmd/model/remove_model.go:125 still bypasses ErrorMessageExcerpt.
R1-4 Redirect reconnect loop Medium Fixed at 252fbf9d Redirects remain permanent stream errors at internal/api/logs.go:575-590.
R1-5 Required live CLI validation Medium Partially fixed The author supplied local-stack evidence before round 2; production API coverage remains explicitly excluded.
R1-6 Missing generated flag docs Low Fixed at 27c46944 Generated docs contain both new flags.
R1-7 Ineffective boundary-redaction test Low Fixed at 3e4bca51, 8def476e Tokens now genuinely straddle the excerpt cut.
R2-1 Redirect credential disclosure Medium Partially fixed at 7952b83b Network-path Location userinfo still survives redact.URL.
R2-2 Status loss on bounded-read failure Medium Not addressed internal/api/client.go:136-138,201-205 still returns the plain read error.
R2-3 Loopback-policy description mismatch Low Fixed Both PR-body statements now require opt-in or a loopback GraphQL API, matching modelUploadHTTPAllowed.

Findings

  1. Medium (R1-3, partially fixed): The dependency-check GraphQL path still permits oversized, unredacted messages. Existing thread.
  2. Medium (R1-5, partially fixed): Round 2 incorrectly said no replacement live evidence existed; comment 4637945015 predates that review and details local-stack runs. The repository requires the changed commands against the live API, which the report explicitly did not cover. Existing thread.
  3. Medium (R2-1, partially fixed): internal/redact/redact.go:37 routes scheme-relative URLs through stripURLText, which cannot remove userinfo without ://; a REST Location: //user:pw@example.test/x therefore still prints credentials. Accept parsed URLs with a nonempty host and clear User, query, and fragment, with GraphQL/log as well as REST regression coverage. Existing thread.
  4. Medium (R2-2, not addressed): A final failed bounded read still erases the received HTTP status and stable codeForStatus result after retries. Preserve both in an APIError. Existing thread.
  5. Low (R3-1): internal/redact/redact.go:145 replaces url.Error.Err with redactedError, whose lack of Timeout/Temporary methods makes the sanitized url.Error report false for both. Callers branching on net.Error.Timeout() can therefore misclassify client timeouts; forward those methods through the wrapper and add a real-client timeout regression test.

Questions

  • Which accompanying change updates the external runpodctl skill for the new flags and behavior? R1-Q1 remains unanswered.
Other reviewers, PR description, CI, nits
  • @deanq’s redirect, GraphQL limit, upload HTTP policy, sensitive-name, and raw-body findings remain addressed at this head: redirects, limit, uploads, names, errors. Human-owned threads were left to their owners.
  • @cursor’s GraphQL redirect finding remains addressed.
  • R1-C1 remains: the PR body says 26 files, +1226/-39; GitHub currently reports 107 files, +2401/-127.
  • Nit cmd/model/add_model_to_repo.go:1789: use lowercase minio to match output conventions.
  • CI at review time: build, fuzz, and all three flake jobs passed; report was skipped. No required checks were configured.
  • Review relied on code inspection and CI. The author’s local unit/race/lint, 1,507-run leak validation, and local-stack results were not independently reproduced; no builds, tests, codegen, or live e2e were run by this reviewer.

Kimi (moonshotai/Kimi-K3.1-Pro) · round 3 · 3 review agents (redaction/security, existing feedback, tests/docs) · 13 min · automated review, a human owns the final call. New commits are checked every 5 min and get an automatic re-review of the changes since this round. Ask for a review: request @justinwlin as a reviewer, comment @justinwlin watcher, review on the PR, or Slack DM @justin.lin Watcher, review https://github.com/runpod/runpodctl/pull/406. Stop re-reviews: Slack DM Watcher, stop https://github.com/runpod/runpodctl/pull/406.

@jebenexer
jebenexer requested a review from justinwlin November 20, 2026 04:53

@justinwlin justinwlin left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimi review, round 4

Verdict: Approved. 0 Critical, 0 High, 6 Medium+Low → approved (approval gate: no Critical/High and fewer than 10 Medium+Low).

Context: This stacked PR hardens authenticated transports and model uploads. This push fixes the remaining redirect, timeout, structured-message, and status-loss findings; four Medium and two Low items remain non-blocking.

Next step: @jebenexer merges; address the six non-blocking findings and complete production validation and cleanup.

Status of prior findings

# Finding Severity Status Evidence
R1-1 Symlink secrets High Fixed at a1938233 Resolved components checked.
R1-2 Truncated uploads High Fixed at a1938233 Identity and size checked.
R1-3 Raw structured errors Medium Fixed at 7314607 remove_model.go:125.
R1-4 Redirect reconnects Medium Fixed at 252fbf9d Redirects are permanent.
R1-5 Live CLI validation Medium Partially fixed Local only; production excluded.
R1-6 Flag docs Low Fixed at 27c46944 Both flags documented.
R1-7 Boundary test Low Fixed at 3e4bca51, 8def476e Token crosses the cut.
R2-1 Redirect credentials Medium Fixed at efad317 Network paths scrubbed.
R2-2 Lost HTTP status Medium Fixed at 7d118f9, 939b384 Status/code retained.
R2-3 Loopback description Low Fixed Description matches code.
R3-1 Timeout classification Low Fixed at 5ede5bf Methods forwarded.

Findings

  1. Medium (R1-5): Production live validation and cleanup remain open. Existing thread.
  2. Medium: Ancestor swaps bypass sensitive alias exclusion. cmd/model/add_model_to_repo.go:729-749.
  3. Medium: Malformed request URLs bypass redaction. api/query.go:62-64.
  4. Medium: Joined batch errors lack a final bound. api/model.go:1168-1192.
  5. Low: Duplicate multi-MB GraphQL tests. api/error_excerpt_test.go:125-171.
  6. Low: Unused exported response wrapper. api/graphql_response.go:94-102.

Questions

  • Which accompanying change updates the external runpodctl skill for the new flags and behavior? R1-Q1 remains unanswered.
Other reviewers, PR description, CI, nits
  • R1-3: Verified fixed in cmd/model/remove_model.go:125. Thread.
  • R2-1/R3-1: Verified fixed in internal/redact/redact.go:40-49,105-127,200-233. Thread.
  • R2-2: Verified fixed through ReadBodyForStatus and unreadableBodyError. Thread.
  • @deanq’s six findings and @cursor’s redirect finding remain addressed; their resolved human/bot threads were not reopened.
  • R1-C1 remains: the PR body says 26 files, +1226/-39; GitHub reports 115 files, +3309/-151. The merge-description head is also stale.
  • Stacked-base follow-up for #405, out of scope and not counted here: deleteVerifiedModelFiles removes absolute paths after hash confirmation, so an ancestor symlink swap can redirect deletion outside the model root. Deletion should use the base PR’s validated root and identity checks.
  • Optional flake jobs failed on new SA1019 lint-baseline warnings for Temporary in internal/redact/redact_test.go; build and fuzz passed, report was skipped, and no required checks are configured.
  • Nit cmd/model/add_model_to_repo.go:1953: use lowercase minio to match output conventions.
  • Review used code inspection and CI. No builds, tests, codegen, race reproductions, leak runs, or live e2e were run by this reviewer; author-reported results were not independently reproduced.

Kimi (moonshotai/Kimi-K3.1-Pro) · round 4 · 4 review agents (model filesystem, API/redaction, tests/docs, existing feedback) · 15 min · automated review, a human owns the final call. New commits are checked every 5 min and get an automatic re-review of the changes since this round. Ask for a review: request @justinwlin as a reviewer, comment @justinwlin watcher, review on the PR, or Slack DM @justin.lin Watcher, review https://github.com/runpod/runpodctl/pull/406. Stop re-reviews: Slack DM Watcher, stop https://github.com/runpod/runpodctl/pull/406.

Comment thread cmd/model/add_model_to_repo.go Resolved
Comment thread api/query.go Resolved
Comment thread api/model.go Resolved
Comment thread api/error_excerpt_test.go Resolved
Comment thread api/graphql_response.go Resolved
@jebenexer
jebenexer force-pushed the benjaminbrannaka/sto-1324-redirects-exit-codes branch from 5ed4331 to 1165af7 Compare November 20, 2026 16:19
…, fail on failed/short uploads

- graphql client refuses every redirect (no api key or body replay), matching the rest client
- server-supplied upload urls must be https (http only for loopback) and are never followed on redirect; 3xx on a part or completion request is a failure
- completion status FAILED, a null part entry and a file that shrinks mid-upload are now errors
- bound model-repo graphql response reads at 32 MiB
- reject backslash and control characters in manifest file names
…clude-hidden

Model file collection now leaves out .git entries (any depth) and .env / .env.*
files (any depth) by default, prints a one-line count of what was skipped, and
--include-hidden restores the previous behavior. Other dotfiles are still uploaded.
…LOW_INSECURE_API=1

Every request that attaches the api key (graphql, rest, logs stream) now checks
its url first. https and loopback http (localhost, 127.0.0.0/8, ::1) always pass;
any other http url is an error naming the opt-ins. The loopback helper moves to
internal/configenv so the model upload url check shares it.
api/pod.go, volume.go, endpoint.go, envOverride.go, modelStatus.go and
cmd/model/remove_model.go now use ReadBoundedResponse, and the rest and typed
graphql clients in internal/api use the shared ReadBounded, so an oversize
response is an error instead of an unbounded buffer.
NewGraphQLClient (template create/update), the rest v2, invoke and log clients
still used a default http.Client, which follows redirects and forwards the
Authorization header to another port on the same host. They now refuse them like
api.Query and the rest client; the graphql sentinel and CheckRedirect are shared
through internal/api.
…ilent 64 KiB cut

parseGraphQLData cut every body at 64 KiB without saying so, so a large valid
response failed with 'unexpected end of JSON input'. It now uses
ReadBoundedResponse (explicit error over the limit) and echoes at most 4 KiB of
a body into an error message.
… api url

Upload urls come from the api response, so a loopback exemption let a
compromised response point the upload at a local listener. Plain http is now
accepted only when --insecure / RUNPOD_ALLOW_INSECURE_API is set or the
configured api url is itself loopback (dev stack); the refusal names the opt-in.
…s by default

Sensitive-entry matching now lowercases names (.ENV on a case-insensitive
volume) and also covers .envrc, .git-credentials and .netrc; .git is skipped
whether it is a directory or a worktree/submodule gitfile. --include-hidden
still re-includes all of them.
…essage

Reads are now capped at 32 MiB, but the '<field> is nil', 'statuscode' and
non-json error paths still printed the whole body. They now use a shared
ErrorBodyExcerpt (redacted, cut at 4 KiB with a marker), including the sites that
predate this PR in cloud.go, pod.go, volume.go and endpoint.go, plus the rest and
typed graphql clients' fallback messages.
…he scan

- An in-root symlink is resolved and its target path is walked component by
  component against the same sensitive-name rules as entry names, so
  alias.bin -> .env or -> .git/config no longer uploads the excluded file
  (skipped and counted unless --include-hidden).
- completeModelUploadWithContext rejects a file whose size differs from the
  scan before deriving chunks, so a single-part file that shrank between
  batch creation and open is not uploaded truncated. exactReader still
  covers a truncation that happens later.
…onse

parseAPIError, the graphql message extractors and every errors[0].message
site now go through ErrorMessageExcerpt, so a valid JSON error envelope with a
multi-megabyte field (or a presigned URL inside one) no longer produces an
unbounded, unredacted error. The signature-straddle excerpt test now computes
its padding so the signature value really crosses the cut.
Follow classified every 3xx APIError as transient and reconnected forever
against a persistently redirecting endpoint. A refused redirect is now
permanent, covered for Follow as well as the classifier.
When ReadBounded rejects (or truncates) the body of a non-2xx response, return an APIError carrying the received status and its stable code instead of the bare read error. Retry behavior is unchanged.
defaultListDependentEndpoints returned the first graphql error message unbounded; wrap it with ErrorMessageExcerpt. Add a table test over the other top-level graphql error paths in api/.
When ReadBounded rejects (or truncates) the body of a non-2xx GraphQL response, return an APIError carrying the received status and its stable code instead of the bare read error. A 2xx response keeps the plain read error. The graphql client, the api package helpers and remove_model share ReadBodyForStatus; the rest client uses the same unreadableBodyError. Retry behavior is unchanged.
Oversized and truncated bodies on 429 and 503 through GraphQLClient.Query and the api helpers keep status and code; a 200 stays a plain read error. The shared writers now set the status after Content-Length so the truncated cases are really truncated.
redact.URL only handled values with a scheme, so a network-path reference
("//user:pw@host/x") kept its userinfo and a REST Location or a refused-redirect
url.Error leaked credentials. Parse any value with a host, always clear the
userinfo, and keep scheme-relative values scheme-relative; the unparsable
fallback strips userinfo from "//authority" too. Tests cover redact.URL, a
sanitized url.Error, and a network-path Location through every api-key client.
redact.Error rebuilt a *url.Error around a plain wrapper, and a *url.Error
answers Timeout/Temporary by asserting on its Err directly, so a timeout turned
into a non-timeout once sanitized and retry logic stopped seeing it. A wrapper
above a cause that has Timeout/Temporary now answers them from the chain (and
only then, so non-network errors do not start to satisfy net.Error). Tests cover
net.Error timeouts, the deadline sentinels, nesting, and a real client timeout.
@jebenexer
jebenexer force-pushed the benjaminbrannaka/sto-1324-redirects-exit-codes branch from 1165af7 to 33d2dab Compare November 20, 2026 16:28

@justinwlin justinwlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimi review, round 5

Verdict: Needs changes. 0 Critical, 0 High, 11 Medium+Low (9 Medium, 2 Low) → current approval gate not met: fewer than 10 Medium+Low are required. Round 4's approval remains in place; this round is a COMMENT, not a dismissal or a new approval.

Context: This push confines post-upload deletion with os.Root and checks the model-directory identity. The new containment tests cover ancestor and root escapes, but two replacement races and three additional unbounded/unredacted API fields remain. All six round-4 findings are still open.

Next step: @jebenexer addresses the 11 findings, including the two deletion races, and completes the repository-required production validation and cleanup before re-requesting review.

Status of prior findings

# Finding Severity Status Evidence
R1-1 Symlink secrets High Fixed at a1938233 Resolved components and rooted identity checks remain present.
R1-2 Truncated uploads High Fixed at a1938233 Scan/open identity and size checks remain present.
R1-3 Raw structured errors Medium Fixed at 7314607 cmd/model/remove_model.go:125 uses the bounded excerpt.
R1-4 Redirect reconnects Medium Fixed at 252fbf9d internal/api/logs.go:572-597 treats redirects as permanent.
R1-5 Live CLI validation Medium Open Local RunPod-in-a-box/LocalStack evidence excludes production API coverage and cleanup.
R1-6 Flag docs Low Fixed at 27c46944 Generated docs contain both flags.
R1-7 Boundary test Low Fixed at 3e4bca51, 8def476e Tokens cross the excerpt cut.
R2-1 Redirect credentials Medium Fixed at efad317 Network-path and absolute redirect targets are scrubbed.
R2-2 Lost HTTP status Medium Fixed at 7d118f9, 939b384 ReadBodyForStatus preserves status/code on failed reads.
R2-3 Loopback description Low Fixed PR description matches the implemented policy.
R3-1 Timeout classification Low Fixed at 5ede5bf Redacted errors forward Timeout and Temporary.

Findings

  1. Medium (R1-5, open): Production built-binary validation and cleanup remain outstanding; the author explicitly scoped live evidence to a local stack. Existing thread.
  2. Medium (R4-2, open): resolved is captured before rooted traversal, so an ancestor swap can upload a sensitive target under a benign alias. cmd/model/add_model_to_repo.go:748-766. Existing thread.
  3. Medium (R4-3, open): Malformed request URLs bypass redact.Error in api/query.go:63, internal/api/graphql.go:77, internal/api/client.go:195, and internal/api/logs.go:296. Existing thread.
  4. Medium (R4-4, open): Individually bounded batch failures are joined without a final bound at api/model.go:1191. Existing thread.
  5. Low (R4-5, open): Duplicate multi-MiB GraphQL tests remain in api/error_excerpt_test.go:125-171. Existing thread.
  6. Low (R4-6, open): The unused exported ReadBoundedResponse wrapper and alias remain in api/graphql_response.go:94-102. Existing thread.
  7. Medium (R5-1): root.Remove(file.deleteName) does not establish that the removed entry is the scanned/uploaded file. During the hash wait, replacing sub/ with sub -> other/ deletes the never-uploaded other/weights.bin; same-name final-entry replacements are also removed and reported successful. Revalidate the scanned entry and ancestor identities before removal, and add an in-root ancestor-swap regression. cmd/model/add_model_to_repo.go:1035-1037.
  8. Medium (R5-2): deleteRootInfo is captured with unpinned os.Lstat. On Windows, the first os.SameFile can lazily reload identity from the replacement root path, making old/new identities compare equal after a real-directory swap. Pin root identity at scan time, preferably via roots.open(0), and cover real-directory replacement. cmd/model/add_model_to_repo.go:718, compared at :1024.
  9. Medium (R5-3): parseAPIError copies an arbitrary server code into the default JSON error without redaction or a size bound. A response-sized credential-bearing code reaches stderr through internal/output/output.go:316. Validate/bound this field and sanitize unexpected values. internal/api/client.go:455.
  10. Medium (R5-4): Invalid string partSizeBytes values are quoted and then repeated through strconv.NumError, exposing an unbounded server string in GraphQL decode errors. Return a bounded redacted excerpt without wrapping the raw parse error. api/model.go:153.
  11. Medium (R5-5): Repetition of a large credential-bearing pagination cursor formats the entire cursor into the returned error. Apply ErrorMessageExcerpt before formatting it. internal/api/client.go:305.

Questions

  • Which accompanying change updates the external runpodctl skill for the new flags and behavior? R1-Q1 remains unanswered.
Existing feedback, PR description, CI, and validation
  • R1-5: Confirmed still open at 33d2dab0; production coverage remains explicitly excluded. Thread.
  • R4-2: Confirmed at cmd/model/add_model_to_repo.go:748-766; the stale lexical resolution predates rooted traversal. Thread.
  • R4-3: Confirmed at all four request-construction paths. Thread.
  • R4-4: Confirmed at the joined batch error in api/model.go:1191. Thread.
  • R4-5: Confirmed; the duplicate suites remain. Thread.
  • R4-6: Confirmed; the wrapper and alias have no production caller. Thread.
  • The earlier human/bot redirect, bounded-read, sensitive-name, and upload-policy findings remain addressed; human-owned threads were not changed.
  • PR description remains stale: it says 26 files, +1226/-39; GitHub reports 115 files, +3310/-152.
  • build and fuzz passed. Optional flake jobs fail on SA1019 warnings for (net.Error).Temporary in internal/redact/redact_test.go; report was skipped. Nix is optional and non-blocking. No required checks are configured.
  • Ran: go build ./... → passed; go test ./... → all packages passed. A temporary in-root ancestor-swap regression reproduced R5-1 (deleted=1 err=<nil> for a non-uploaded replacement), then was removed; the clone is clean.
  • R5-2 was verified against Go 1.26.11's Windows loadFileId/sameFile implementation, not executed on Windows. No live RunPod API calls or secrets were used.

Kimi (moonshotai/Kimi-K3.1-Pro) · round 5 · 4 review agents (model filesystem, API/redaction, tests/docs/conventions, existing feedback) · 20 min · automated review, a human owns the final call. New commits are checked every 5 min and get an automatic re-review of the changes since this round. Ask for a review: request @justinwlin as a reviewer, comment @justinwlin watcher, review on the PR, or Slack DM @justin.lin Watcher, review https://github.com/runpod/runpodctl/pull/406. Stop re-reviews: Slack DM Watcher, stop https://github.com/runpod/runpodctl/pull/406.

Comment thread cmd/model/add_model_to_repo.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread internal/api/bodylimit.go Resolved
…l skips

Review follow-ups:

- the sensitive-entry check for a scanned file now resolves the file's
  root-relative path THROUGH the pinned containment root (per-component
  lstat + readlink), so a directory swapped for a link to .git between the
  lexical resolution and the rooted stat cannot upload a sensitive file
  under its alias; stale lexical targets are no longer trusted.
- http.NewRequest construction failures go through redact.Error at all
  four sites (empty class): api.Query, internal GraphQLClient.Query,
  Client.send, LogClient.stream; a malformed url no longer quotes its
  query (signatures) into the message or the chain's *url.Error.
- the batch-finalize failures list is bounded as a whole (on top of each
  alias message's own excerpt), so hundreds of failing sessions cannot
  print megabytes; covered by a 64-alias regression test.
- consolidate the duplicated multi-MiB graphql message suites into one,
  keeping a dedicated path-resolved c0 alias case.
- drop the exported test-only ReadBoundedResponse wrapper and the
  maxModelResponseBytes alias; tests use internalapi.ReadBounded /
  MaxResponseBytes directly.
- a server-provided error "code" is only kept when it has a conventional
  machine-code shape (bounded, single line); anything else is dropped and
  the code is derived from the status, so a response-sized blob cannot
  reach the JSON error object.
- APIError gains Unwrap over a new unexported cause, set by
  unreadableBodyError, so a rejected response whose body died with a
  connection reset keeps its status and code AND still classifies as a
  network error for the retry signal.
- redact tests stop asserting the deprecated Temporary() (SA1019 flagged
  by the nix lint-baseline flake jobs); Timeout() classification stays
  pinned.
- close the unused (usually nil) response in the malformed-url query test
  with the repo's checked-close idiom (bodyclose + errcheck).
- split collectModelFilesWithOptions: the per-entry walk logic moves to a
  modelDirScan.collectEntry method, with resolveEntryTarget and
  traversesSensitive helpers, same check order, messages and pinned-root
  semantics (gocognit 55 -> under the limit). error values that chained
  into the same name get their own (statErr, sensErr), clearing the govet
  shadow reports.
- range the file slices by index in the hidden-files tests (rangeValCopy,
  136 bytes per entry).
- the network-cause assertions use errors.AsType with both results
  consumed (modernize), no directives.

@justinwlin justinwlin left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimi review, round 6

Round 6 approval stands. New findings since 33d2dab0, for the author to consider:

Verdict: Approved. 0 Critical, 0 High, 7 Medium+Low → approval gate passes (7 < 8).

Context: Most round-5 fixes are present; two new and five carried-forward Medium findings remain.

Next step: Address findings 1–7; the existing approval remains.

Status of prior findings

# Finding Severity Status Evidence
R1-1 Symlink secrets High Fixed Rooted checks remain.
R1-2 Truncated uploads High Fixed Size checks remain.
R1-3 Raw structured errors Medium Fixed Excerpts remain.
R1-4 Redirect reconnects Medium Fixed Redirects are permanent.
R1-5 Live CLI validation Medium Partially fixed Local runs exclude production.
R1-6 Flag docs Low Fixed Docs updated.
R1-7 Boundary test Low Fixed Boundary covered.
R2-1 Redirect credentials Medium Fixed Targets scrubbed.
R2-2 Lost HTTP status Medium Fixed Status preserved.
R2-3 Loopback description Low Fixed Policy matches.
R3-1 Timeout classification Low Fixed Classification preserved.
R4-2 Sensitive ancestor swaps Medium Partially fixed Direct swaps are caught; nested symlink/.. bypass remains at add_model_to_repo.go:972.
R4-3 Request-construction leaks Medium Fixed at 4d6fdc96 All four error chains are redacted.
R4-4 Joined batch failures Medium Fixed at 4d6fdc96 Final joined error is bounded.
R4-5 Duplicate large tests Low Fixed at 4d6fdc96 Duplicate suite removed.
R4-6 Unused bounded-read API Low Fixed at 4d6fdc96 Wrapper and alias removed.
R5-1 Replacement deletion Medium Fixed at 4d6fdc96 Root and entry identities are revalidated; R6-1 covers in-place writes.
R5-2 Lazy root identity Medium Fixed at 4d6fdc96 Root identity pinned before walking.
R5-3 Server error code Medium Fixed at 4d6fdc96 Codes are bounded and shape-checked.
R5-4 Raw partSizeBytes Medium Not addressed api/model.go:153 still wraps the raw value.
R5-5 Raw repeated cursor Medium Not addressed internal/api/client.go:307 still quotes it.
deanq Lost network cause Medium Partially fixed Cause unwraps, but emitted JSON keeps the HTTP-derived code.

Findings

  1. Medium (R1-5, partially fixed): Production built-binary validation and cleanup remain outstanding. Existing thread.
  2. Medium (R4-2, partially fixed): Precleaning nested link targets lets x -> .git/sub, safe -> x/../secret upload .git/secret while checking benign secret; reproduced alias collection. Existing thread.
  3. Medium (R5-4, not addressed): Invalid partSizeBytes remains unbounded and unredacted at api/model.go:153.
  4. Medium (R5-5, not addressed): Repeated pagination cursors remain unbounded and unredacted at internal/api/client.go:307.
  5. Medium (R6-1): Post-upload in-place rewrites are deleted because cleanup checks only identity at add_model_to_repo.go:1284; reproduced.
  6. Medium (R6-2): Unrecognized XML markup exposes arbitrary fields after tag stripping at add_model_to_repo.go:2037-2055; reproduced SignatureProvided disclosure.
  7. Medium (deanq, partially fixed): output.Error chooses the HTTP-derived code before network fallback at internal/output/output.go:314-328, so preserving the cause does not emit network_error. Existing thread.

Questions

  • Which accompanying change updates the external runpodctl skill for the new flags and behavior? R1-Q1 remains unanswered.
Existing feedback, PR description, CI, and validation
  • R4-3: Verified fixed; all four constructor error chains are sanitized. Thread.
  • R4-4: Verified fixed after joining batch failures. Thread.
  • R4-5: Verified fixed; duplicate large-response coverage was removed. Thread.
  • R4-6: Verified fixed; unused exported wrapper and alias were removed. Thread.
  • R5-2: Verified fixed; root identity is pinned at scan time. Thread.
  • R5-3: Verified fixed; server codes are sanitized. Thread.
  • deanq on internal/api/bodylimit.go:38: Partially fixed; the cause unwraps, but output.Error still emits the HTTP-derived code. Human-owned threads left unresolved. Original, follow-up.
  • deanq on cmd/model/add_model_to_repo.go:840: Confirmed an additional R4-2 swap-back variant; grouped with finding 2. Thread.
  • Earlier human/bot redirect, bounded-read, sensitive-name, and upload-policy findings remain addressed.
  • PR description remains stale: it says 26 files, +1226/-39; GitHub reports 119 files, +3774/-221. Cursor metadata also names an older commit.
  • build, fuzz, and all optional flake jobs passed; optional nix report was skipped. No required checks are configured.
  • Ran: go build ./... → passed; go test ./api ./cmd/model ./internal/api ./internal/output ./internal/redact → all five packages passed.
  • Reproduced R4-2, R6-1, and R6-2 with temporary focused tests (three expected failures); tests were removed and the clone is clean. Windows behavior was not executed. No live RunPod API calls or secrets were used.

Kimi (moonshotai/Kimi-K3.1-Pro) · round 6 · 4 review agents (model filesystem, API error hardening, tests/conventions, existing feedback) · 12 min · automated review, a human owns the final call. New commits are checked every 5 min and get an automatic re-review of the changes since this round.

How to ask for a Kimi review: GitHub: request @​justinwlin as a reviewer, or comment @​justinwlin w​atcher, review on the PR. Slack: DM @​justin.lin W​atcher, review <PR link>. New commits get an automatic re-review (checked every 5 min). Stop it: DM W​atcher, stop <PR link>.

Comment thread api/model.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium (R5-4, not addressed): At api/model.go:153, invalid string partSizeBytes values are still embedded with %q and retained in a wrapped strconv.NumError. A large credential-bearing GraphQL value therefore reaches stderr twice, unbounded and unredacted; return an errorMessageExcerpt-sanitized value without wrapping the raw parse error, with a large signed-value regression test.

Comment thread internal/api/client.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium (R5-5, not addressed): At internal/api/client.go:307, a server-supplied repeated pagination cursor is still quoted verbatim into the returned error. Two pages repeating a large credential-bearing nextCursor can dump nearly the full response field to stderr; apply ErrorMessageExcerpt before formatting and cover a long signed cursor.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium (R6-1): The identity-only check at cmd/model/add_model_to_repo.go:1284 still authorizes deletion after a regular checkpoint is truncated and rewritten in place, because os.SameFile remains true. A temporary test reproduced deletion of post-upload edits; record post-upload metadata or a content digest and refuse deletion on changes, covering same-size and size-changing rewrites.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium (R6-2): summarizeStorageError at cmd/model/add_model_to_repo.go:2037-2055 strips unrecognized markup to text, so <ErrorResponse><SignatureProvided>deadbeef</SignatureProvided></ErrorResponse> returns deadbeef in the upload error; this was reproduced. Return unrecognizedXMLErrorText for unrecognized XML/markup or strictly constrain HTML handling, and retain the unwrapped regression case.

Comment thread internal/api/bodylimit.go
// ReadBounded refused (oversized) or could not finish (cut short). The response
// itself was received, so the error keeps its status and stable code rather
// than the bare read error -- but the (redacted) read error stays reachable
// through Unwrap, so a transient network failure behind the body still

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the Unwrap, errors.As now reaches the *net.OpError. One gap against the comment here: output.Error picks the code from ErrorCode() first and only checks for a network error when the code is empty. So a 502 whose body read hits ECONNRESET still emits server_error, and a 4xx with a reset body keeps its non-retry code. The JSON a script sees is unchanged.

If keeping the HTTP status is the intent, could the comment say the cause is reachable with errors.As but the status sets the emitted code? If you want a retry signal for scripts, output.Error would need to prefer the network code when an APIError wraps a net.Error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: internal/output/output.go:314-328 chooses APIError.ErrorCode() before fallbackCode, so the emitted JSON still uses server_error/api_error. My earlier reply overstated the result: Unwrap makes isNetworkError(err) true but does not change the output code. The implementation and comments should make the intended precedence explicit and test output.Error.

// the components the confined resolution actually traverses are checked
// too (not the stale lexical `resolved`).
if !s.includeHidden {
sensitive, sensErr := s.traversesSensitive(path, rootIdx, rootRel, info.IsDir())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

traversesSensitive walks the path again after the rooted lstat has recorded the identity, and the upload later checks only identity (Open plus SameFile), not sensitivity. Sequence: safe is a link to .git during the lstat, so the recorded identity is .git/config; safe is swapped back to a real directory before traversesSensitive runs, so it passes; safe is swapped back to the link before the upload, and Open plus SameFile match, so .git/config uploads under the alias. I read this from the code order and have not reproduced it.

TestCollectModelFiles_SkipsAliasWhoseAncestorSwappedToSensitiveDuringScan swaps only before the lstat, so it narrows the window without closing it. Would re-running traversesSensitive next to the SameFile check at upload time be reasonable? Or is a local writer swapping links mid-run outside the threat model for this flag?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: the scan records identity at add_model_to_repo.go:830, checks sensitivity afterward at :839-847, and the upload at :1107-1130 rechecks only regularity and identity. The benign swap between those operations therefore passes while a later restoration reaches the same sensitive inode. This is another R4-2 variant; recheck the traversed components at upload time and add this swap-back sequence to the regression coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants