Skip to content

fix: security hardening round 2 (v7.4.1)#99

Merged
GeiserX merged 1 commit intomainfrom
fix/security-hardening-round2
Mar 31, 2026
Merged

fix: security hardening round 2 (v7.4.1)#99
GeiserX merged 1 commit intomainfrom
fix/security-hardening-round2

Conversation

@GeiserX
Copy link
Copy Markdown
Owner

@GeiserX GeiserX commented Mar 31, 2026

Summary

Addresses 4 findings from second security review pass.

  • Avatar ACL bypass (Medium): serve_media() and serve_thumbnail() now extract chat_id from avatar filenames (avatars/{users|chats}/{chat_id}_*.jpg) and enforce per-chat scoping for restricted users. Previously, the avatars/ prefix bypassed ACL entirely.
  • Push endpoint spoofing (Medium): /internal/push now supports an optional INTERNAL_PUSH_SECRET env var. When set, the notifier sends it as a bearer token and the viewer validates it — preventing co-tenant containers from spoofing live events. IP-only auth remains as fallback for backward compatibility.
  • Reaction recovery data loss (Medium): After a duplicate-key sequence error, insert_reactions() now retries ALL reactions in a fresh transaction instead of just the one that triggered the error. The previous return after a single retry lost all remaining reactions.
  • Push unsubscribe ownership (Low): POST /api/push/unsubscribe now scopes the DELETE to the requesting user's username, preventing cross-user endpoint removal.

Test plan

  • 167 tests pass (pytest tests/ --ignore=tests/test_telegram_import.py)
  • Verify restricted user cannot access /media/avatars/chats/<other_chat_id>_*.jpg
  • Verify INTERNAL_PUSH_SECRET blocks requests without matching bearer token
  • Verify push unsubscribe only removes own subscriptions

…nsubscribe (v7.4.1)

- Avatar ACL: extract chat_id from avatar filenames to enforce per-chat
  scoping for restricted users (serve_media + serve_thumbnail)
- /internal/push: add optional INTERNAL_PUSH_SECRET bearer token to
  prevent co-tenant containers from spoofing live events
- Reaction recovery: retry ALL reactions after sequence reset, not just
  the one that triggered the duplicate-key error (rollback loses all)
- Push unsubscribe: scope DELETE to requesting user's username to prevent
  cross-user endpoint removal
@github-actions
Copy link
Copy Markdown

🐳 Dev images published!

  • drumsergio/telegram-archive:dev
  • drumsergio/telegram-archive-viewer:dev

The dev/test instance will pick up these changes automatically (Portainer GitOps).

To test locally:

docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev

@GeiserX GeiserX merged commit 1242bf1 into main Mar 31, 2026
7 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.

1 participant