Home/Projects/Haq/Security testing
Read in your language

हिन्दीবাংলাEspañolFrançaisDeutschMore languages

Opens Google Translate, which sends this page's text to Google. The English is the reference. The Haq app itself has Hindi, Bengali, Spanish, French and German built in, offline.

Security testing

How Haq was attacked before release, what was found and fixed, and how to run the same tests again.

Legal information, not legal advice Haq shows what the law says and where to go. Only the police and courts decide what an offence is. Check every result and act at your own discretion.

Haq handles sensitive moments: abuse, injuries, threats. It keeps everything on the person's device and never sends a report anywhere by itself. Before 1.0.1 was released, it was tested the way an attacker would try to break it. No security settings were changed for this; the tests check the settings that were already there.

What was tried#

Attack Result
Script and HTML code typed into every field on Report, SOS, Schemes and the privacy check, carried through to the route page, the complaints, the FIR PDF and the evidence pack Shown as plain text everywhere. Nothing ran, with or without the security headers.
A file with code in its name added as evidence Shown as text.
Code in links (#example=…, page addresses) Ignored.
Code planted in the browser's storage (language, translation server, SOS contact) Ignored; an unsafe translation server address falls back to the default.
Every rule pack rewritten with code in every text, with fingerprints updated (as if the repository were taken over) Shown as text on every page. Nothing ran.
A rule pack changed without updating its fingerprint Refused: "failed its integrity check".
Another website putting Haq in a frame (clickjacking) Blocked by frame-ancestors 'none' and X-Frame-Options: DENY.
Code running inside the page trying to send data out: fetch, an image pixel, an outside script, a form post, sendBeacon Blocked by the Content Security Policy. eval and new Function are blocked too.
Email header injection through typed text in the email complaints Not possible: everything in a mailto: link is encoded.
A 250,000-character text in the privacy check (slow-pattern attack) Finished in under a second.
What stays on the device after a full report Only the language choice. No names, numbers, places or files; no cookies.
What leaves the device during a full report Nothing. No request goes to any other site.

What was found and fixed#

  1. Optional translation could send typed details. When someone pressed Translate the whole page (a feature that is off until chosen), the page's text went to the translation server, including a place and an SOS contact's name that the page showed back to them. Now any page text that contains something the person typed, or the name of a file they picked, is left out. Tested on the summary, the route page and SOS: nothing typed is sent.
  2. Words like "toString" or "__proto__" were mistranslated. In Hindi or Bengali, the offline translator could show "[object Object]" instead of such words, because it read them from JavaScript's built-in object. It now reads only its own dictionary. This could not run code, but it changed what the person wrote.

Still worth knowing#

  • The security headers (Content Security Policy, frame blocking, no referrer, HSTS and others) are set in app/_headers and served by Cloudflare. The tests ran against a local copy that sends the same headers.
  • GitHub Actions use least privilege (contents: read for tests) and no pull_request_target. Pinning actions to commit hashes instead of version tags would harden them further.
  • A translation API key, if someone sets one, is kept in the browser's storage on their device, as the privacy notice says.

Run the tests yourself#

From the repository root, with Python 3, Node 18+ and Playwright (npm i -D playwright):

sh security/run.sh

It builds Haq, makes the poisoned and tampered copies (security/prepare.py), serves them with and without the production headers (security/serve.py), and runs the attacks in security/*.mjs. Every check should report no findings.

Haq is free to use. © Abhisek Goswami, all rights reserved. Suggestions, translations, legal reviews and feedback are welcome.

Still need help?

Email me directly and I'll reply myself, usually within two working days. Please don't include personal details of your case.