Skip to content

Harden bot outbound requests and bound avatar decoding - #179

Merged
iamxvbaba merged 1 commit into
iamxvbaba:mainfrom
xirogram:codex/upstream-security-fixes
Nov 15, 2026
Merged

iamxvbaba merged 1 commit into
iamxvbaba:mainfrom
xirogram:codex/upstream-security-fixes

Conversation

@clockerka

Copy link
Copy Markdown
Contributor

Bot webhook delivery can currently connect to loopback/private services, and bot download validation checks DNS separately from the connection. Avatar uploads also decode images before checking their pixel dimensions. This PR closes those paths and updates the vulnerable dependencies found during review.

Changes

  • Introduce a shared outbound dialer that resolves once, rejects private/local/reserved addresses and mixed DNS answers, and connects to the validated numeric IP.
  • Use the dialer for webhook delivery and bot download checks. Disable HTTP proxies on these transports to prevent proxy-side DNS from bypassing the checks; retain normal TLS certificate verification and the webhook redirect prohibition.
  • Check avatar byte and pixel limits before full decoding, including emoji/sticker avatar overlays.
  • Require Go 1.26.11, update the Docker builder, upgrade vulnerable dependencies, and add a pinned govulncheck step to CI.
  • Add regression tests for IP pinning, mixed DNS answers, private webhook destinations, explicit internal-network opt-in, and oversized avatar uploads.

Compatibility

Webhook delivery now permits public IP destinations by default. Trusted self-hosted deployments needing internal webhooks can explicitly set TELESRV_BOT_API_WEBHOOK_ALLOW_PRIVATE_NETWORKS=true; this grants every bot access to the server's internal network. Proxy environment variables are ignored for webhook delivery and bot download checks. The option and network behavior are documented in the Bot API guide and configuration reference.

Validation

Run locally with Go 1.26.11:

  • go test ./... -count=1
  • go vet ./...
  • go test -race ./internal/safehttp ./internal/botapi -count=1
  • go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 -show verbose ./... — no vulnerabilities found, including module-only results.
  • python3 scripts/gen_admin_panel_doc_tables.py --check
  • git diff --check

PostgreSQL-dependent and live Compose tests were skipped locally because their required services are not running.

This is the security subset of the changes merged in xirogram#6, rebased onto this repository's main branch.

Copilot AI balanced review requested due to automatic review settings November 15, 2026 10:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@iamxvbaba
iamxvbaba merged commit c99078b into iamxvbaba:main Nov 15, 2026
4 checks passed
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.

3 participants