Why it matters
GetFile returns a temporary path; treat downloads as untrusted binary input.
Practical steps
- Resolve the file with getFile then fetch the file URL
- Cap download bytes before writing disk
- Allowlist extensions and verify magic bytes
- Virus-scan in an isolated worker
- Never log URLs that embed the bot token
Watch out for
- Copy-pasting outdated snippets for telegram file downloads without re-reading current official docs.
- Shipping telegram file downloads to production without a staging rehearsal and a documented rollback.