mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 07:01:27 -07:00
oops, just return a fake signature
This commit is contained in:
+19
-13
@@ -13,25 +13,31 @@ key:
|
||||
back to the bundled `static/DefaultProfileImage.jpg` asset (served `200` via
|
||||
the `ASSETS` binding), so clients always get a valid image. The fallback also
|
||||
honours `?sig=p1` and returns a `Content-Signature` header.
|
||||
- `GET /<key>?sig=p1` — same, but the response body is RSA-SHA1 signed and the
|
||||
signature returned in a `Content-Signature: key-id=KEY:RSA:p1.rec.net; data=<base64>`
|
||||
header. The client uses this to verify image integrity. **Off by default** —
|
||||
see below.
|
||||
- `GET /<key>?sig=p1` — same, plus a
|
||||
`Content-Signature: key-id=KEY:RSA:p1.rec.net; data=<base64>` header. By default
|
||||
that value is a **placeholder, not a real signature** — see below.
|
||||
|
||||
The bucket is bound in the Worker as `env.IMAGES` (see `wrangler.jsonc`).
|
||||
|
||||
## Response signing
|
||||
|
||||
Signing is behind the `IMG_SIGNING_ENABLED` var in `wrangler.jsonc`, and it is
|
||||
**`false`**. It is the worker's dominant CPU cost: signing has to buffer the
|
||||
whole object into the isolate rather than streaming it out of R2, then hash the
|
||||
full body with SHA-1 and run an RSA-2048 private-key operation — on every request
|
||||
the edge cache misses. Nothing verifies the header today, so with the flag off
|
||||
`?sig=p1` is accepted and ignored, and untransformed images stream through
|
||||
untouched.
|
||||
The client requires a `Content-Signature` header to be present when it asks for
|
||||
`?sig=p1`, but it never verifies the value. Signing for real is this worker's
|
||||
dominant CPU cost: it has to buffer the whole object into the isolate rather than
|
||||
streaming it out of R2, then hash the full body with SHA-1 and run an RSA-2048
|
||||
private-key operation — on every request the edge cache misses.
|
||||
|
||||
Flip the var to `true` to turn it back on. (Resizes still buffer regardless — the
|
||||
Photon codec needs the whole image.)
|
||||
So by default (`IMG_SIGNING_ENABLED: false` in `wrangler.jsonc`) the header is
|
||||
filled with a placeholder derived from the object key: FNV-1a seeds an xorshift32
|
||||
PRNG that emits 256 bytes, the length of a real RSA-2048 signature, so the value
|
||||
is structurally indistinguishable to the client's parser and stable for a given
|
||||
key. It costs no body access, so untransformed images keep streaming.
|
||||
|
||||
Set the var to `true` for genuine RSA-SHA1 signatures over the returned bytes.
|
||||
Note this is a **placeholder, not a downgrade of a security control** — nothing
|
||||
in the system authenticates images either way. Turn it on before relying on the
|
||||
header for integrity. (Resizes buffer regardless — the Photon codec needs the
|
||||
whole image.)
|
||||
|
||||
### Signing key
|
||||
|
||||
|
||||
Reference in New Issue
Block a user