Repository navigation
fix(tlon): guard memex upload target - #69794
Conversation
Greptile SummaryThis PR fixes an SSRF vulnerability in the Tlon Memex upload path by replacing a raw Confidence Score: 5/5Safe to merge — no correctness or security issues in the changed code. All findings are P2 style suggestions. The SSRF guard is correctly applied, No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/tlon/src/tlon-api.ts
Line: 249-255
Comment:
**`release()` acquired before `try` — consider wrapping the guard call too**
`fetchWithSsrFGuard` is called on line 236 before the `try` block begins on line 249, so `release` is only in scope within the guarded `try/finally`. This is technically safe because if `fetchWithSsrFGuard` itself throws, there is nothing to release. However, the pattern is fragile: if any code is inserted between the destructuring and the `try` (e.g. a logging call, a second await), a thrown exception there would leak the acquired guard resource. Suggested defensive refactor using an optional `release?.()` in the `finally`:
```typescript
let release: (() => Promise<void>) | undefined;
try {
const guarded = await fetchWithSsrFGuard({
url: uploadUrl,
init: {
method: "PUT",
body: params.blob,
headers: {
"Cache-Control": "public, max-age=3600",
"Content-Type": contentType,
},
},
auditContext: "tlon-memex-upload",
});
release = guarded.release;
if (!guarded.response.ok) {
throw new Error(`Upload failed: ${guarded.response.status}`);
}
} finally {
await release?.();
}
```
This is a style hardening — the current code is correct in all foreseeable paths today.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/tlon/src/tlon-api.test.ts
Line: 62-64
Comment:
**Redundant `mockClear` after `vi.clearAllMocks()`**
`vi.clearAllMocks()` (line 62) already resets call history and return values on every mock including `mockRelease`, so `mockRelease.mockClear()` on line 64 is a no-op and can be removed.
```suggestion
vi.clearAllMocks();
vi.stubGlobal("fetch", vi.fn());
mockAuthenticate.mockResolvedValue("urbauth-~zod=fake-cookie");
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/tlon/src/tlon-api.test.ts
Line: 120-147
Comment:
**Missing assertion that `release` is not called on guard rejection**
The blocked-target test correctly asserts that the error propagates, but doesn't assert that `mockRelease` was never called. Adding `expect(mockRelease).not.toHaveBeenCalled()` would lock in that no resource is leaked (or erroneously released) on the rejection path, complementing the `toHaveBeenCalledTimes(1)` assertion in the success test.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(tlon): guard memex upload target" | Re-trigger Greptile |
9b7d657 to
9c65ea4
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6cc73271d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89861ff1c2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efc220e4d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
432fa28 to
0d2931d
Compare
8267577 to
717237f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 717237fc5b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
0117278 to
c8595a8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8595a8ada
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a67245ba3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Untrusted ship-provided custom S3 endpoint allows exfiltration of uploaded blobs to attacker-controlled public hosts
DescriptionIn the custom S3 upload path, the plugin uses storage credentials obtained from the connected ship (via Because the endpoint is not allowlisted/confirmed and Key points:
Vulnerable code: const endpoint = new URL(prefixEndpoint(credentials.endpoint));
const client = new S3Client({ endpoint: { /* derived from ship-provided endpoint */ }, ... });
...
const signedUrl = await getSignedUrl(client, command, { ... });
...
await fetchWithSsrFGuard({
url: signedUrl,
init: { method: "PUT", body: params.blob, ... },
...
});RecommendationTreat ship-provided custom S3 credentials as untrusted configuration and prevent silent uploads to arbitrary public hosts. Options (choose based on product requirements):
function assertAllowedCustomS3Endpoint(raw: string): URL {
const url = new URL(prefixEndpoint(raw));
if (url.protocol !== "https:") throw new Error("Custom S3 endpoint must use https");
const allowed = ["s3.example.com", "nyc3.digitaloceanspaces.com"]; // example
if (!allowed.includes(url.hostname)) throw new Error("Unapproved storage endpoint");
return url;
}
Also consider logging/auditing the final hostname used for custom S3 uploads to aid detection. Analyzed PR: #69794 at commit Last updated on: 2026-04-21T21:55:57Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7c26aa13b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
e7c26aa to
db4687a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db4687a4ac
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
db4687a to
f36d0a1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f36d0a11c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
47e6d07 to
42bb8de
Compare
42bb8de to
0e6fd7b
Compare
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
* fix(tlon): guard memex upload target * fix(tlon): harden guarded memex upload * fix(tlon): validate hosted memex upload targets * fix(tlon): tighten hosted domain matching * fix(tlon): reject non-standard memex upload ports * fix(tlon): disable memex upload redirects * test(tlon): drop redundant mock resets in memex upload test * chore(lint): update tlon raw-fetch allowlist for guarded memex upload * fix(tlon): reject unparseable ship URLs in hosted-ship classifier * fix(lint): point tlon raw-fetch allowlist at fetch callee lines * fix(tlon): guard custom-S3 upload through fetchWithSsrFGuard * fix(tlon): preserve scheme-less hosted ship routing and allow explicit :443 * docs(changelog): note tlon upload guard * fix(tlon): guard memex lookup and private s3 opt-in * fix(tlon): validate upload result URLs
fix(tlon): guard memex upload target
Summary
Describe the problem and fix in 2–5 bullets:
If this PR fixes a plugin beta-release blocker, title it
fix(<plugin-id>): beta blocker - <summary>and link the matchingBeta blocker: <plugin-name> - <summary>issue labeledbeta-blocker. Contributors cannot label PRs, so the title is the PR-side signal for maintainers and automation.fetch().uploadFile()now sends Memex upload targets throughfetchWithSsrFGuardand releases the guarded dispatcher after the request completes; a new unit test covers the guarded success path and blocked-target failure path.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.extensions/tlon/src/tlon-api.tsaccepted Memex'surlfield and passed it directly tofetch()instead of using the repo's existing SSRF-guarded fetch helper.fetchWithSsrFGuardor that blocked targets surface a guard failure.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.extensions/tlon/src/tlon-api.test.tsfetchWithSsrFGuardwith the returned upload URL, and blocked private/link-local targets fail through that guard instead of reaching rawfetch().User-visible / Behavior Changes
Hosted Tlon Memex uploads now fail before the PUT request if the returned upload URL resolves to a blocked private or loopback target. Public upload URLs continue to use the same upload flow.
Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/ARepro + Verification
Environment
https://groups.tlon.network) and mocked Memex responses in unit testsSteps
uploadFile(...), asserting the PUT goes throughfetchWithSsrFGuard.Expected
Actual
uploadFile()now routes Memex upload targets throughfetchWithSsrFGuard, and the added unit test passes for both the allowed upload path and blocked-target failure path.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
extensions/tlon/src/tlon-api.test.tsandextensions/tlon/src/urbit/upload.test.ts, then ranpnpm check:changed --staged, which passed extension typecheck, lint, import-cycle checks, and 112 extension-messaging tests.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.