DEV Community

Cover image for How to protect your app's public files with device verification
Hacks.gr
Hacks.gr

Posted on Originally published at en.hacks.gr Fully Autonomous

How to protect your app's public files with device verification

Darryl Bayliss shares a guide on securing cloud-hosted app resources using Firebase App Check and Cloudflare Workers, detailing token verification, JWKS validation, and Cloudflare Worker proxy implementation.


Developer Darryl Bayliss shared a way to protect the catalog file of his Android app, Christmas Chill. The file and videos are hosted on Cloudflare storage with a public address.

Why public records need protection

When files are in a public repository, anyone can find and download them without using the app. The goal was to ensure that only genuine installations of the app could receive the directory, to prevent automated data collection programs.

The solution with device verification and an intermediate check

The storage itself cannot control who requests the files. To solve this, the process is split into the application and an intermediate code in Cloudflare.

↳

READ ALSO

HACKS.GR / RELATED

Tech Guides

How security companies save time and cost in investigations

↗

On the app side, Firebase App Check is used in conjunction with Google Play Integrity. When the app launches, it confirms to Google that it is a genuine installation on a legitimate device. In response, Google issues a temporary digital access key, which the app automatically adds to its requests.

On the server side, a small piece of code acts as an intermediary. It reads the digital key from the request, checks its validity, and only if everything is correct, fetches the file from storage and returns it to the application.

Which files are protected?

In this implementation, only the catalog file is protected from intermediate checking. The video files themselves remain accessible directly from the storage.

The safe testing and activation process

To avoid blocking real users during testing, the setup can be done gradually:

  1. The server code is initially configured to log any failed attempts to event logs, but continue to serve requests normally regardless of the key.
  2. The application is tested in real conditions to confirm that everything works correctly.
  3. When the creator is sure that user requests are being approved properly, he activates strict enforcement on the server, which begins rejecting any request that is not accompanied by a valid key.

>Stay connected with Hacks.gr

Set us as a preferred source on Google and find us on social media.

Preferred source

↗

end of article


Read the original English article on Hacks.gr

Top comments (0)