fix(line): migrate media downloads to saveMediaBuffer for sandbox access#42010
fix(line): migrate media downloads to saveMediaBuffer for sandbox access#42010carrotRakko wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes a sandbox access regression for LINE media downloads by migrating from Key findings:
Confidence Score: 4/5
Last reviewed commit: b89fd9a |
|
The attack prerequisite (write access to ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved) |
…nd improve MIME detection Migrate LINE media downloads from buildRandomTempFilePath (/tmp) to saveMediaBuffer (~/.openclaw/media/inbound/) so files are accessible inside the sandbox. Also: - Switch from getMessageContent to getMessageContentWithHttpInfo to capture the Content-Type header from LINE API responses. - Pass originalFilename (from LINE file messages) through to saveMediaBuffer, enabling extension-based MIME fallback in detectMime. - Remove the local detectContentType/getExtensionForContentType helpers (now handled by saveMediaBuffer's detectMime pipeline). ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
Addresses Greptile review: `httpResponse.httpResponse.headers` was confusing because the outer variable shadowed the SDK property name. ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I did a careful shell check against current Current main now implements this PR's central LINE sandbox-access fix in the active bundled plugin layout: LINE inbound media is persisted through Best possible solution: Close this PR as implemented on main by What I checked:
So I’m closing this as already implemented rather than keeping a duplicate issue open. Codex review notes: model gpt-5.5, reasoning high; reviewed against db40ec404a91; fix evidence: commit 4e921808d18a. |
Summary
/tmpviabuildRandomTempFilePath, which is outside the sandbox root (~/.openclaw/media/). Sandboxed agents cannot access downloaded LINE media files (images, videos, audio, documents).<media:...>placeholders but the files are inaccessible.downloadLineMedianow usessaveMediaBuffer(writes to~/.openclaw/media/inbound/), captures theContent-Typeheader from LINE API responses, and passesoriginalFilenamefrom file messages through todetectMimefor extension-based MIME fallback.saveMediaBufferitself (only thefilePathargument todetectMimewas missing). No new dependencies.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
~/.openclaw/media/inbound/instead of/tmp/openclaw/. Sandboxed agents can access these files.Content-Typefrom LINE API response headers is now used for MIME detection, improving accuracy over buffer-only sniffing.filemessages (PDF, DOCX, etc.) now preserve the original filename in the saved file path, enabling extension-based MIME fallback for uncommon file types.Security Impact (required)
NoNoNo— same LINE API endpoint, switched fromgetMessageContenttogetMessageContentWithHttpInfo(same HTTP call, richer response object)NoNo— files move from/tmpto~/.openclaw/media/inbound/, both are local storage.saveMediaBufferapplies the same size limits.Yes, explain risk + mitigation: N/ARepro + Verification
Environment
channels.linewith sandbox enabledSteps
~/.openclaw/media/inbound/for the downloaded fileExpected
~/.openclaw/media/inbound/with correct MIME type and extensionActual (before fix)
/tmp/openclaw/line-media-*.extEvidence
download.test.tstests updated to match the newsaveMediaBuffer-based flow (mocksaveMediaBufferinstead offs.writeFile).Human Verification (required)
download.ts,bot-handlers.ts, andstore.tsto confirm the changes are still applicable (no upstream changes to these code paths since the original fork implementation).originalFilenameisundefinedfor non-file message types (image/video/audio) —saveMediaBufferhandles this gracefully. Oversized media rejection still works (streaming size check beforesaveMediaBuffercall).Review Conversations
N/A — fresh PR, no review conversations yet.
Compatibility / Migration
Yes— media files are now saved to a different path, but all consumers use the returnedpathfromdownloadLineMedia, not hardcoded paths.NoNoFailure Recovery (if this breaks)
/tmpstorage (non-sandbox-accessible).~/.openclaw/media/inbound/after download.Risks and Mitigations
getMessageContentWithHttpInfoAPI may behave differently across@line/bot-sdkversions (response shape).httpResponse.headersexists. TheContent-Typeheader extraction has a?? undefinedfallback for missing headers.✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)