Engineering
Tauri CSP Was Off and Uploads Allowed SVG
Ankik desktop exposed all native APIs and S3 accepted SVG. We locked CSP, capped uploads at 10MB, and fixed sort injection.
Ankik desktop shipped with Content Security Policy set to null. That means disabled. At the same time withGlobalTauri exposed all native APIs to any injected script. On the server, presigned S3 uploads had no size cap and allowed SVG, which is stored XSS. Email templates interpolated names raw.
This post records the Oct 05 security batch that closed these holes. Tauri CSP shipped as fix for issue 67, PR 97. Input sanitization shipped as fix for issue 54, PR 95. Extra hardening covered PASETO key separation in PR 92 and dependency auditing in PR 98.
What the holes meant
A disabled CSP plus global Tauri exposure means one injected script reaches native APIs. That turns a small XSS into a desktop compromise. SVG uploads mean stored XSS: the file itself carries the script and fires for every viewer. Raw userName in OTP email HTML means content injection at login, the most visited flow.
Founders feel this as one incident that erases trust. Shops handle money in Ankik. A compromised invoice view ends the product relationship.
My first instinct was wrong
I first treated desktop and server as separate reviews. I queued the CSP work behind backend tickets. The commit history shows why that order was wrong. The renderer already used explicit module imports only, with zero window.__TAURI__ references. The CSP fix needed no code changes at all. It waited only on my attention.
I also assumed presigned PUT URLs carried our size limits. They do not express a range. Without exact length signing, undeclared sizes stay unconstrained. Scope kept the full POST migration out, so we signed exact lengths instead.
The Tauri fix
We set a restrictive CSP: scripts self only, styles self plus inline for Radix runtime injection, images self plus asset plus data plus the S3 media host, connect self plus IPC plus API origins per environment plus dev HMR, fonts self plus asset plus data, object and frame locked down. We set withGlobalTauri false.
Verification was a full Tauri build producing MSI and NSIS bundles with the new config. No renderer changes were needed because imports were already explicit: api core invoke, plugin opener, plugin store.
The server fixes
Four findings, one PR:
- F1:
userNameinterpolated raw into OTP email HTML. We added a sharedescapeHtmlhelper in common utils and applied it at both OTP template boundaries. - F2: presigned PUT had no size cap and allowed
svgandimage/svg+xml. We removed SVG from allowlists, added optional file size validated againstMAX_UPLOAD_BYTESof 10MB with S3 ContentLength exact match signing, and the web client now sendsfile.size. - F3: raw
sortByreached the ORM in 5 listing services for parties, invoices, purchases, expenses, and proposals, surfacing 500s. We added a sharedvalidateSortParamsallowlist helper that returns 400 withINVALID_SORT_FIELDorINVALID_SORT_ORDER. - F4: invoice update bound the DTO as
any, bypassing whitelist validation. We typed it asUpdateInvoiceDto, which the service already expected.
Verification was the full jest suite at 43 of 43 files with 432 tests, plus typecheck, lint, and backend plus web builds green.
What else shipped around it
PASETO tokens got key domain separation for access and refresh tokens in PR 92. Security logs got the business guard plus forbidNonWhitelisted in the fix for issue 65. Dependency auditing landed as report only in PR 98 because the tree carries about 30 pre existing high and critical transitive advisories that would fail CI closed on day one. Dependabot alerts need a repo admin toggle, confirmed separately.
| Area | Before | After |
|---|---|---|
| Desktop CSP | Null, disabled | Restrictive per-source policy |
| Tauri API surface | Global exposure on | Explicit imports only |
| S3 uploads | No cap, SVG allowed | 10MB exact match, SVG removed |
| Sort params | Raw strings hit ORM | Allowlist, 400 on abuse |
| Invoice DTO | any bypassed whitelist | Typed DTO enforced |
What we kept and what we gave up
We kept report only auditing instead of a closed gate. Failing CI on 30 inherited advisories would block security fixes themselves. The gate flips once the baseline clears.
We gave up SVG uploads entirely. Some users like vector logos. Stored XSS risk outweighs that nicety in a money app.
One edge remains. PUT URLs cannot express a size range, so undeclared sizes stay unconstrained until a presigned POST migration. That work sits outside this scope and stays tracked.
FAQ
How do I check my Tauri CSP today?
Read your Tauri config. If the policy is null, you ship disabled. Set per-source values and build both bundles to confirm.
Why remove SVG instead of sanitizing it?
Sanitizers drift with parser quirks. Removal ends the class. Raster logos cover the need.
Why keep auditing report only?
A closed gate on 30 inherited advisories blocks every PR including fixes. Report first, remediate baseline, then enforce.
Did PASETO separation change tokens?
It separates keys by domain for access and refresh. Verify with existing auth tests before rotating.
Next step
If you ship Tauri plus a Nest backend, run this checklist this week. Read your CSP value. Grep for global Tauri references. List your upload allowlist. Send one raw sort param at each listing endpoint. Each check takes minutes and each hole costs trust.
For related reading, see our proxy trust fix that stopped false 429s and the analytics deletion that cut 284 lines. To review your app security posture, contact us through the build sprint page.
OUR WORK

Book-Hotels-B2B
2026B2B travel agency platform with quote-to-invoice automation.

Ankik
2026Desktop-first accounting workspace for SMEs, 0 to launch.

Retainix
2025Multi-branch loyalty & cashback platform for petrol pumps & retail.
BOOK A CALL
Ready to turn your idea into a live product?
Schedule a 15-minute scoping call with Dhanji below. We'll discuss your scope, timeline, and tech strategy honestly.

