Wrap fetched content in untrusted output markers#577
Open
VACInc wants to merge 5 commits intoopenclaw:mainfrom
Open
Wrap fetched content in untrusted output markers#577VACInc wants to merge 5 commits intoopenclaw:mainfrom
VACInc wants to merge 5 commits intoopenclaw:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--wrap-untrustedandGOG_WRAP_UNTRUSTEDto opt into external untrusted-content wrappers for JSON/raw output fields that carry fetched Google Workspace/API text.externalContentmetadata.Problem
Google API fetches can return email bodies, document text, sheet cells, notes, comments, titles, and names that may later be pasted into LLM/agent contexts.
gogdid not have an output-level untrusted boundary similar to OpenClaw's web fetch/search wrappers.Root Cause
Fetched Google content and stable metadata were emitted through the same JSON/raw writers. Agents had to remember which fields were external content rather than getting explicit untrusted-content markers at the output boundary.
Exact Change
internal/outfmtwrapping helpers that recursively inspect JSON-compatible payloads, wrap content-bearing strings in<<<EXTERNAL_UNTRUSTED_CONTENT ...>>>markers, and sanitize nested marker spoofing.WriteJSONandWriteRawwhen the root context enables it.--wrap-untrustedflag andGOG_WRAP_UNTRUSTEDenv default.Scope Boundary
This only changes JSON/raw output when
--wrap-untrustedorGOG_WRAP_UNTRUSTED=1is set. It does not change default output, plain/table output, Google API requests, auth behavior, or mutation semantics.Real behavior proof
Behavior fixed: opt-in Google fetched text fields are marked as external untrusted content while metadata stays machine-usable.
Environment: local unit tests in this checkout, using the real
outfmt.WriteJSON/outfmt.WriteRawpaths and root flag parsing.Command:
go test ./internal/outfmt ./internal/cmdCopied output:
Observed result: wrapper tests confirm content fields and sheet values contain
EXTERNAL_UNTRUSTED_CONTENT, IDs/URLs/document IDs remain unwrapped, spoofed start/end markers are sanitized, metadata-only payloads are not annotated, and both the flag and env default enable the wrapper.Verification
go test ./internal/outfmt ./internal/cmdgo test -vet=off ./...make fmt-checkBlocked or unrelated check attempts
make fmt-checkattempt exited 2 after running the formatter tools because the feature Go diff was still intentionally unstaged; reran after staging the formatted files and it passed.What was not tested