Urgent.News

What's breaking now, across thousands of outlets.

Tech

Stop User ID Spoofing in React Telegram Mini Apps with PHP HMAC Auth

When developers build a Telegram Mini App—whether it is a digital storefront, a seat booking system, or a lead capture workflow—they often fall into a critical security trap. The Telegram WebApp SDK exposes an object named window.Telegram.WebApp.initDataUnsafe . This object conveniently contains parsed information about the current Telegram user, including their numeric id , first_name , username…

The article discusses the security risks associated with user ID spoofing in React Telegram Mini Apps and provides a solution using PHP HMAC Auth. The Telegram WebApp SDK exposes an object called initDataUnsafe that contains user information, which can be easily accessed by frontend developers and manipulated by malicious actors.

This can lead to unauthorized access to private data, balance depletion, and modification of database records. To secure Telegram Mini Apps, the article recommends treating initDataUnsafe as untrusted metadata and using raw, unparsed strings stored in window.Telegram.WebApp.initData. The recommended authentication workflow involves verifying an HMAC-SHA256 signature using the Telegram Bot Token and generating a short-lived JSON Web Token (JWT) or session token upon successful verification.

All subsequent API calls should use the JWT in the Authorization header, with the backend decoding the JWT to identify the user and ignoring any user ID provided in client request bodies.

Brief written by urgent.news from Dev.to's own syndicated text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Parsing and Stripping EXIF Metadata Completely In-Browser with JavaScript ArrayBuffers

Every smartphone photo you take embeds precise metadata inside the file: GPS latitude and longitude, camera serial numbers, lens focal lengths, and timestamps.

  • ScanMetadata runs entirely in browser memory using ArrayBuffer and DataView
  • JPEG file composed of sequential binary segments with EXIF metadata in APP1 segment
  • LocateExifSegment function reads first 128KB to find EXIF segment start offset

Why PDF image extractors return the stored picture, not the one on the page

Every extractor I pointed at my test PDF gave me back a rotated picture unrotated and a half-hidden picture whole. After three years of codec work I took that as the correct answer, but I wanted to be…

  • PDF image extractors return stored picture, not visible page image
  • Tools like pdfimages, PyMuPDF, pdf.js show stored pixels
  • D image returns page colors, applying /Decode and ignoring clip

A copyable MCP tool-cost check for CI, with passing and failing examples

A tool's description can shrink while its schema grows. A single token total can hide that regression. Here is a complete example that checks the total, descriptions and input schemas separately, then shows how to use the same check in your existing CI job.

  • Tool cost regression detected by CI check
  • HISTOR tool lists verified for expected counts and digests
  • CI integration with baseline snapshot for ongoing monitoring

More from Sunday 25 October →