Skip to content

H10: harden Telegram outbound-media allowlist and add approval gate#57

Merged
jkyberneees merged 1 commit into
mainfrom
fix/h10-telegram-media-allowlist
Jul 18, 2026
Merged

H10: harden Telegram outbound-media allowlist and add approval gate#57
jkyberneees merged 1 commit into
mainfrom
fix/h10-telegram-media-allowlist

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Closes H-10.

Changes

  • internal/telegram/media_path.go:

    • Rejects paths classified as system_write or higher by danger.ClassifyPath (e.g. ~/.ssh, ~/.aws, ~/.gnupg, ~/.odek trust anchors).
    • Rejects any file whose basename starts with .env (case-insensitive), even inside an allowed project directory.
    • Adds BroadBaseWarning() to warn when the bot is launched from $HOME or /.
  • internal/telegram/approver.go:

    • Adds PromptMedia(path), which prompts for the network_egress risk class, shows the full file path, and includes the broad-base warning when applicable.
  • internal/telegram/handler.go:

    • sendMedia now requires an explicit approval via the per-chat `TelegramApprover\ before resolving/uploading the file. Fails closed if no approver is registered.
  • cmd/odek/telegram.go:

    • The send_message tool sender closure now calls PromptMedia before uploading any file.
  • Tests:

    • Added regression tests for secret-subtree rejection, .env rejection, broad-base warning, and PromptMedia approve/deny/warning behavior.
    • Updated existing MEDIA-prefixed handler/e2e tests to register an auto-approving stub approver.
  • Docs:

    • Updated AGENTS.md and docs/SECURITY.md to describe the new gate and restrictions.

Verification

  • go test ./... -count=1
  • go test -race ./cmd/odek/ ./internal/telegram/ -count=1

- ResolveMediaPath now rejects well-known secret subtrees and .env* files
  even when they sit inside an otherwise allowed base directory.
- Added BroadBaseWarning to warn when the bot is launched from /Users/kyberneees or /.
- Added TelegramApprover.PromptMedia for explicit user approval of outbound
  media uploads, with the broad-base warning surfaced in the prompt.
- Wired the gate into Handler.sendMedia (MEDIA: prefix) and the send_message
  tool sender closure.
- Updated affected tests and added regression tests for secret-subtree
  rejection, .env rejection, broad-base warning, and PromptMedia behavior.
- Updated AGENTS.md and docs/SECURITY.md.
@jkyberneees
jkyberneees merged commit cb190ff into main Jul 18, 2026
6 of 7 checks passed
@jkyberneees
jkyberneees deleted the fix/h10-telegram-media-allowlist branch July 18, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant