Repository navigation
Conversation
When a user shares a file or image in Nextcloud Talk, the webhook
delivers object.content as a JSON-encoded rich object message like:
{"message":"{file}","parameters":{"file":{"type":"file","name":"IMG.jpg","link":"https://..."}}}
Previously payloadToInboundMessage() passed this raw JSON string as
text, leaving mediaUrls unpopulated and the agent blind to attachments.
This change adds parseRichObjectContent() which:
- Detects JSON-encoded rich object payloads
- Extracts file links into mediaUrls
- Resolves {placeholder} names for human-readable displayText
- Falls back to raw content for non-rich-object text (no behaviour change)
Also updates NextcloudTalkInboundMessage type to include mediaUrls?,
passes mediaUrls through inbound.ts to the agent context payload, and
relaxes the empty-body guard to allow media-only messages through.
Fixes openclaw#29152
Greptile SummaryThis PR adds rich object parsing to the Nextcloud Talk webhook handler so that file and image shares are properly delivered to the agent as Key changes:
Confidence Score: 3/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/nextcloud-talk/src/monitor.ts
Line: 193-198
Comment:
**SSRF risk from unvalidated host in extracted URLs**
The regex `/^https?:\/\//i` only validates the URL scheme, not the destination host. A malicious or compromised Nextcloud instance could craft a rich object with `link: "https://169.254.169.254/latest/meta-data"` (AWS metadata endpoint) or `link: "https://192.168.1.1/"` (internal network resource), and the agent would receive those URLs as `mediaUrls` and potentially fetch them.
Consider validating the parsed `URL` host against known internal address ranges, or at minimum logging/stripping URLs whose hostname resolves to a private/loopback range:
```ts
function isSafeHttpUrl(raw: string): boolean {
try {
const u = new URL(raw);
if (u.protocol !== "https:" && u.protocol !== "http:") return false;
const h = u.hostname;
// Reject loopback, link-local and RFC-1918 ranges
if (/^(localhost|127\.|0\.0\.0\.0|::1$|10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|169\.254\.)/.test(h)) return false;
return true;
} catch {
return false;
}
}
```
This is especially important because the attachment payload originates from a user-controlled message body that has only been HMAC-authenticated at the *sending Nextcloud server* level — a user who can send a webhook to this bot (or who controls the Nextcloud instance) can supply arbitrary link values.
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/nextcloud-talk/src/monitor.ts
Line: 209-213
Comment:
**Raw JSON string surfaced to agent for valid rich objects with no placeholder matches**
When `parseRichObjectContent` is called on a valid JSON rich object whose `message` string contains no `{placeholder}` tokens matching any parameter key — for example a future NC Talk type like `{"message": "reacted with 👍", "parameters": {"reaction": {"type": "reaction", "id": "1"}}}` — the function finds `mediaUrls.length === 0 && !hadPlaceholders` and returns `null`.
The caller then sets `text = rawContent`, which is the **raw JSON string**, not the human-readable `"reacted with 👍"`. The agent ends up seeing `{"message":"reacted with 👍","parameters":{...}}` as the message body.
A simpler approach would be to always return the resolved `displayText` when the JSON was successfully parsed as a rich object, even if no substitutions occurred:
```ts
// After the loop, instead of the current guard:
return {
displayText: displayText.trim(),
mediaUrls: mediaUrls.length > 0 ? mediaUrls : undefined,
};
```
This way the agent always gets the human-readable `parsed.message` for any well-formed rich object, and the current early-`null` path (when JSON.parse fails or structure doesn't match) still handles non-rich-object plain text correctly.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "fix(nextcloud-talk):..." |
| if ( | ||
| param?.type === "file" && | ||
| typeof param.link === "string" && | ||
| /^https?:\/\//i.test(param.link) | ||
| ) { | ||
| mediaUrls.push(param.link); |
There was a problem hiding this comment.
SSRF risk from unvalidated host in extracted URLs
The regex /^https?:\/\//i only validates the URL scheme, not the destination host. A malicious or compromised Nextcloud instance could craft a rich object with link: "https://169.254.169.254/latest/meta-data" (AWS metadata endpoint) or link: "https://192.168.1.1/" (internal network resource), and the agent would receive those URLs as mediaUrls and potentially fetch them.
Consider validating the parsed URL host against known internal address ranges, or at minimum logging/stripping URLs whose hostname resolves to a private/loopback range:
function isSafeHttpUrl(raw: string): boolean {
try {
const u = new URL(raw);
if (u.protocol !== "https:" && u.protocol !== "http:") return false;
const h = u.hostname;
// Reject loopback, link-local and RFC-1918 ranges
if (/^(localhost|127\.|0\.0\.0\.0|::1$|10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|169\.254\.)/.test(h)) return false;
return true;
} catch {
return false;
}
}This is especially important because the attachment payload originates from a user-controlled message body that has only been HMAC-authenticated at the sending Nextcloud server level — a user who can send a webhook to this bot (or who controls the Nextcloud instance) can supply arbitrary link values.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/nextcloud-talk/src/monitor.ts
Line: 193-198
Comment:
**SSRF risk from unvalidated host in extracted URLs**
The regex `/^https?:\/\//i` only validates the URL scheme, not the destination host. A malicious or compromised Nextcloud instance could craft a rich object with `link: "https://169.254.169.254/latest/meta-data"` (AWS metadata endpoint) or `link: "https://192.168.1.1/"` (internal network resource), and the agent would receive those URLs as `mediaUrls` and potentially fetch them.
Consider validating the parsed `URL` host against known internal address ranges, or at minimum logging/stripping URLs whose hostname resolves to a private/loopback range:
```ts
function isSafeHttpUrl(raw: string): boolean {
try {
const u = new URL(raw);
if (u.protocol !== "https:" && u.protocol !== "http:") return false;
const h = u.hostname;
// Reject loopback, link-local and RFC-1918 ranges
if (/^(localhost|127\.|0\.0\.0\.0|::1$|10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|169\.254\.)/.test(h)) return false;
return true;
} catch {
return false;
}
}
```
This is especially important because the attachment payload originates from a user-controlled message body that has only been HMAC-authenticated at the *sending Nextcloud server* level — a user who can send a webhook to this bot (or who controls the Nextcloud instance) can supply arbitrary link values.
How can I resolve this? If you propose a fix, please make it concise.| // Return if we have files OR if we resolved any placeholders (non-file rich objects | ||
| // like mentions, deck cards, polls — don't discard their resolved displayText) | ||
| if (mediaUrls.length === 0 && !hadPlaceholders) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Raw JSON string surfaced to agent for valid rich objects with no placeholder matches
When parseRichObjectContent is called on a valid JSON rich object whose message string contains no {placeholder} tokens matching any parameter key — for example a future NC Talk type like {"message": "reacted with 👍", "parameters": {"reaction": {"type": "reaction", "id": "1"}}} — the function finds mediaUrls.length === 0 && !hadPlaceholders and returns null.
The caller then sets text = rawContent, which is the raw JSON string, not the human-readable "reacted with 👍". The agent ends up seeing {"message":"reacted with 👍","parameters":{...}} as the message body.
A simpler approach would be to always return the resolved displayText when the JSON was successfully parsed as a rich object, even if no substitutions occurred:
// After the loop, instead of the current guard:
return {
displayText: displayText.trim(),
mediaUrls: mediaUrls.length > 0 ? mediaUrls : undefined,
};This way the agent always gets the human-readable parsed.message for any well-formed rich object, and the current early-null path (when JSON.parse fails or structure doesn't match) still handles non-rich-object plain text correctly.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/nextcloud-talk/src/monitor.ts
Line: 209-213
Comment:
**Raw JSON string surfaced to agent for valid rich objects with no placeholder matches**
When `parseRichObjectContent` is called on a valid JSON rich object whose `message` string contains no `{placeholder}` tokens matching any parameter key — for example a future NC Talk type like `{"message": "reacted with 👍", "parameters": {"reaction": {"type": "reaction", "id": "1"}}}` — the function finds `mediaUrls.length === 0 && !hadPlaceholders` and returns `null`.
The caller then sets `text = rawContent`, which is the **raw JSON string**, not the human-readable `"reacted with 👍"`. The agent ends up seeing `{"message":"reacted with 👍","parameters":{...}}` as the message body.
A simpler approach would be to always return the resolved `displayText` when the JSON was successfully parsed as a rich object, even if no substitutions occurred:
```ts
// After the loop, instead of the current guard:
return {
displayText: displayText.trim(),
mediaUrls: mediaUrls.length > 0 ? mediaUrls : undefined,
};
```
This way the agent always gets the human-readable `parsed.message` for any well-formed rich object, and the current early-`null` path (when JSON.parse fails or structure doesn't match) still handles non-rich-object plain text correctly.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9a2d08593
ℹ️ 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".
| typeof param.link === "string" && | ||
| /^https?:\/\//i.test(param.link) | ||
| ) { | ||
| mediaUrls.push(param.link); | ||
| } |
There was a problem hiding this comment.
Propagate MIME types for extracted rich-object media
The new rich-object parser only emits mediaUrls from parameters[*].link and drops each file parameter’s mimetype, so downstream context gets URLs without usable type hints. In this codebase, attachment routing relies on MIME/extension classification (src/media-understanding/attachments.select.ts and src/media-understanding/attachments.normalize.ts), and Nextcloud share links are commonly extensionless (/f/<id>), so these attachments are frequently classified as unknown and skipped by image/audio/video handling. This means shared files can still fail to reach media understanding despite being parsed as attachments; include and forward per-attachment MIME data (e.g., MediaTypes) alongside URLs.
Useful? React with 👍 / 👎.
Array.push() returns number, not void. Wrap in block to satisfy void | Promise<void> constraint.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92bbfe1b08
ℹ️ 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".
| param?.type === "file" && | ||
| typeof param.link === "string" && | ||
| /^https?:\/\//i.test(param.link) | ||
| ) { | ||
| mediaUrls.push(param.link); |
There was a problem hiding this comment.
Restrict rich-object parsing to trusted Nextcloud payloads
This parser treats any message body that looks like {"message":...,"parameters":...} as a rich object and immediately forwards parameters[*].link URLs as attachments, so an allowed user can send plain JSON text with a crafted http(s) URL and have it ingested as media. In deployments where media understanding is enabled, those URLs are later fetched by the attachment cache (src/media-understanding/attachments.cache.ts), which turns a normal chat message into arbitrary outbound fetches (SSRF surface) that did not exist before this commit. The parsing path should be constrained to trusted Nextcloud rich-object payloads (or otherwise enforce stricter origin validation for extracted links) before promoting links into mediaUrls.
Useful? React with 👍 / 👎.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open as a useful but non-merge-ready implementation candidate: current main and v2026.6.10 still do not parse Nextcloud Talk rich-object file shares into agent-visible media, but this branch needs MIME propagation, trusted-origin URL handling, current-main refresh, and positive real file-share proof before merge. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Source-reproducible: current main and v2026.6.10 still pass Nextcloud Talk rich-object content through as text and never set inbound Is this the best way to solve the issue? No as-is: the plugin boundary is right, but the branch is stale and omits the MIME metadata, trusted-link policy, and real file-share proof needed for a safe fix. Security review: Security review needs attention: Security review needs attention because the diff adds a new media URL promotion path without a channel-level Nextcloud origin or account-policy trust check.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against d1b917120a47. |
|
Hi @VivoKrei — gentle ping on this. Running OpenClaw with Nextcloud Talk as one of my main channels and the inability to see images/files users share is a real pain point. +1 voice for getting this merged. @maintainers — anything blocking this besides the codex-bot request for behavior proof? Happy to help test against a live NC Talk + OpenClaw setup if that helps move it forward. |
|
Hands-on test report from a live NC Talk + OpenClaw 2026.5.12 setup (Ubuntu 24.04, npm install of Test setupI patched the three changes from this PR directly into the bundled
Restarted gateway, all 9 plugins loaded clean, no startup errors. Results✅ Backwards compatibility confirmedPlain text messages continued to work unchanged — 🔍 Useful observation about real NC Talk payloadsIn live traffic, every message — even plain text — arrives as a rich-object JSON string in {"type":"Note","name":"message","content":"{\"message\":\"hello\",\"parameters\":[]}"}Note that
❌ Could not validate the file-share path end-to-endI tried sending images from the Nextcloud Talk web client multiple times. The webhook never fired for those messages (no inbound payload reached the patched code at all — verified with This appears to be an upstream NC Talk bot configuration issue (file-share events may need explicit subscription, or the bot user lacks file-read permission in the room) rather than a problem with this PR — but it means I cannot post a "real attachment → agent received mediaUrl" trace for the codex-bot here. The PR code path is sound; the gating issue is in NC Talk itself. Outbound media (separate gap)Also worth noting: outbound media from the agent to NC Talk does not work either (sending an image attachment via the agent results in only the text body being delivered, dropping the file). The sendMedia: async ({ cfg, to, text, mediaUrl, ... }) =>
await sendMessageNextcloudTalk(to, mediaUrl ? `${text}\n\nAttachment: ${mediaUrl}` : text, ...)That is a separate issue (not in scope of this PR) but the channel will still feel asymmetric until it lands too. VerdictThe PR diff is small, well-scoped, defensively coded (http(s) only, malformed JSON fallback, replaceAll for repeated placeholders), and ships with both unit and signed-webhook integration tests. The backwards-compatibility property held in a real running gateway. From a user perspective this is strictly an improvement and would unblock a real pain point. Recommend merging. Happy to retest once the inbound side merges, and to assist with the outbound counterpart in a follow-up PR. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
@steipete please take a look |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Fixes #29152
When a user shares a file or image in Nextcloud Talk, the bot webhook receives the message but the NC Talk plugin was not parsing the rich object parameters — so the agent never saw the attachment.
NC Talk encodes file shares as rich object messages where
object.contentis a JSON string:{"message":"{file}","parameters":{"file":{"type":"file","id":"12345","name":"IMG_123.jpg","path":"Talk/IMG_123.jpg","link":"https://cloud.example.com/f/12345","mimetype":"image/jpeg","preview-available":"yes"}}}Previously
payloadToInboundMessage()passed this raw JSON string astext, leavingmediaUrlsunpopulated.Changes
monitor.tsparseRichObjectContent()helper that detects JSON-encoded rich object payloadsmediaUrls(https/http only — rejectsfile://,javascript:, etc.){placeholder}names for human-readabledisplayText(covers file shares, mentions, deck cards, polls, etc.)replaceAllfor placeholder substitution to handle duplicate occurrencescontentfor non-rich-object text — no behaviour change for regular messagestypes.tsmediaUrls?: string[]toNextcloudTalkInboundMessageinbound.tsMediaUrlsintofinalizeInboundContext(verified: already consumed natively asstring[])Tests
monitor.attachment.test.ts— 7 unit tests: file share, text passthrough, malformed JSON fallback, name fallback, mention resolution,file://URL rejection, multi-filemonitor.live-integration.test.ts— 5 integration tests using real HMAC-signed payloads against the webhook serverAll 12 tests pass. TypeScript compiles clean (
tsc --noEmit).Before / After
Before: Sharing a file in NC Talk → agent receives raw JSON string, never sees the attachment.
After: Sharing a file → agent receives
text = "filename.jpg"andmediaUrls = ["https://..."]— can immediately process the image via vision without any manual workaround.