Filelayer

One file feature, built five ways

A B2B document workspace, built five times: once with Filelayer and four times the way each platform's own documentation recommends. Then the same scripts count what each one asks the developer to write and to get right, and the same 26 attacks are run against every version that can run.

The workspace is the same in all five: organizations and roles, upload, per-role access, share links with an expiry, a password and a download cap, revocation of a link already handed out, and an audit trail.

Everything here is reproducible from a fresh clone with one command, and every number comes from data in the repository that you can change to get your own.

git clone https://github.com/filelayer/filelayer.git
cd filelayer
node benchmark/run.mjs

It needs Node 22.18 or later, no account, no credential and no environment variable. The network is used for npm and nothing else.

The five implementations

ImplementationBuilt withRan?
Filelayer@filelayer/core 0.37.0 from npm, on PostgreSQLYes
SupabaseSupabase Storage and Postgres row-level securityYes: real RLS policies on PostgreSQL (PGlite), with the platform schema emulated
Raw S3S3 or R2 presigned URLs and PostgresYes: against a local store that verifies SigV4 signatures
ConvexConvex and its R2 componentNo, not executed and not compiled: it needs a live Convex deployment and an R2 bucket
Vercel BlobVercel Blob (a private store) and PostgresNo, not executed and not compiled: private Blob delivery has no local emulation

Who built them. We did, in September 2026. Each alternative was written by a separate AI agent, told to follow its platform's documented best practice and to argue for that platform. Each one's directory has a REPORT.md with its sources, what it could not implement, and a section called "Where this approach is genuinely good". The brief they were built from and the prompt each agent was given in September were not kept. benchmark/BRIEF.md says so, lists every phrase of the brief that the agents quoted in their reports with its file and line, and publishes the two prompts used since: the cold review of 3 November and the revision round of 13 November. The Filelayer version is the examples/vault/server.ts that ships in the npm package, and a second copy of it wired as in production is counted beside it. The attack suite was written by the same team that builds Filelayer. That is a conflict of interest, and the section on the attacks says what we did about it.

The two alternatives that ran were revised against the attacks. The library was fixed each time the attacks found a defect in it; the alternatives were frozen after one build. So on 13 November each executed alternative got a round against the attacks, at most 40 changed lines of application code, done the way someone who knows the platform would do it. Supabase got a second change on 14 November, after a later review: its share gateway streams the bytes instead of redirecting to a signed URL. Raw S3 changed 39 lines in one round, Supabase 24 in two rounds, all of them application code; Supabase's diff also holds 11 lines of the platform emulation. Every diff is published in benchmark/revisions/, and every result below is for the revised code. Convex and Vercel Blob have never run, so their code was not changed; their counts assume they were built the way their platforms document.

Results

Security-sensitive decisions

A decision here is a point where the developer can choose an option that leaks or loses data and nothing reports it: no error, no failing test, no warning. Counted as kinds, and as the places in the code where each must be got right.

ImplementationKindsPlaces
Filelayer810
Supabase2549
Raw S32432
Vercel Blob, not executed or compiled2236
Convex, not executed or compiled1919

Over the two alternatives that ran, the average is about 3.1 times as many kinds and 4.0 times as many places.

One rule for all five. A decision enforced in one helper is one place, however many call sites use the helper. A decision is dropped when the platform's own linter flags the wrong choice, or when the safe choice is the platform's default and leaving it takes a deliberate act: then the wrong choice is not silent. That rule removed two decisions from Filelayer (a private bucket and bucket versioning, both defaults), the same defaults wherever an alternative counted them, the two Supabase decisions its database linter flags, and a repeated count wherever one helper carries the decision. Filelayer's count also gained three decisions its own example has to get right: the routes that create organizations and actors must check an operator credential, the new organization's owner must be the caller and not a name from the request body, and the request body needs a size limit. The example got all three wrong until 0.35.4, and gets them right since. Every change is recorded in decisions.json on the decision itself, with its reason. One Filelayer decision is listed as arguable; counting it gives Filelayer 9 kinds. On the other side, one Supabase decision, writing every row-level security policy for the right command, carries 19 of its places, one per policy. Counted as a single place, Supabase has 31 places instead of 49, and the average for places is about 3.1 times as many, against 4.0.

Two decisions that the first count in September held against Filelayer are no longer in it, because the library fixed them in 0.3.0: the audit chain could fork under concurrent writers, and a download cap was not charged on direct reads. Both are listed in decisions.json under removedSinceGate1, with the test that now holds each.

The Convex and Vercel Blob counts come from their authors' own lists only. The attack suite added decisions to both executed alternatives that their authors had missed, and it cannot do that for code that does not run, so those two counts are probably low. That works against Filelayer and is left as it is.

Lines the developer writes

Non-blank, non-comment application lines. Tests, tooling and the platform emulation are not counted. The Filelayer library itself is not counted either: it is vendor code, the way the Supabase or AWS SDK is.

ImplementationApplication linesInfrastructure configRelative
Filelayer, the example15701.0x
Filelayer, wired as in production19340
Supabase56903.6x
Raw S3708864.5x
Convex, not executed or compiled8410
Vercel Blob, not executed or compiled88416

Wired as in production, the two alternatives that ran take about 2.9 times as many lines as Filelayer: an average of 681.5 against 233, application and infrastructure lines together. That is the number to compare if you are comparing deployments. The example runs on an in-memory database and in-memory storage, and the alternatives are counted with their production wiring, so the same example is also counted wired as a deployment needs it: a pg pool, the schema applied once under a lock, S3Storage, and the IAM and bucket policy it needs. It runs end to end against PostgreSQL and an S3 store (benchmark/production-wired/).

Against the example as it ships, the average of the two is 638.5 application lines against 157, about 4.1 times as many. Both figures leave out Convex and Vercel Blob, which are listed for completeness: code that was never executed or compiled may not even work.

Filelayer's audit log is hash-chained, and neither alternative chains its log. Leaving the chain out of both alternatives' counts, as a check on how much of the gap it explains, still gives about 3.5 times as many lines against the example, and 2.9 and 3.9 times as many kinds and places of decision. Wired as in production, it gives about 2.6 times as many lines against Filelayer wired as in production.

The library is not nothing. Its code runs in your process and its schema in your database, so it is counted too, apart from the lines you write:

ImplementationVendor lines in your processVendor lines in your database
Filelayer6,878547
Raw S342,010 (the AWS SDK)0
Supabase, Convex, Vercel Blobnot measurednot measured

Non-blank, non-comment lines, the same method as above; count-vendor.mjs says what is included. Supabase's vendor code runs on its platform and its schemas are emulated here, and the other two never ran, so a number for them would be a guess.

Every inclusion and exclusion is a rule in benchmark/loc.manifest.json, and a file that matches no rule fails the run.

The 26 attacks

Written once, in benchmark/adversarial/attacks.mjs. They run over HTTP against Filelayer and raw S3, and as direct calls into the application's functions for Supabase, whose platform is emulated.

The comparison uses only the 21 attacks that every executed implementation can express. All three defend every one of them.

ImplementationDefendedPartialBreach
Filelayer 0.37.021 of 2100
Raw S321 of 2100
Supabase21 of 2100
filelayer-prerebuild (control)16 of 2122

Before the revisions, neither raw S3 nor Supabase recorded a refused cross-tenant read, or probes at documents that do not exist, in the application's own audit trail. Nothing was disclosed, and gateway or load balancer logs may have held them. A few lines closed it in both; the diffs are in benchmark/revisions/.

Supabase's share gateway was also revised. It first redirected to a short-lived signed URL, so a revoked link kept working until that URL expired and the audit recorded the issuing of a URL rather than a delivery. It now streams the bytes with the service key, as an Edge Function would, which costs egress through the function. The redirect remains as an option in the code, and its own measurements still run; it is not the version compared here.

The other 5 attacks are reported apart and never added into that comparison. Four test a feature only Filelayer has here: per-file visibility inside a tenant, share listing, lifecycle states and delegation. The fifth depends on whether the application serves the bytes itself. Filelayer defends all 5. Raw S3 can express only the fifth, HTML uploaded and opened on the signed-in read path: its presigned URL asks S3 to serve the file as an attachment, which real S3 does and the local store here does not implement, so it is reported as "pass, not executed", not as a pass. Supabase can express none. "Cannot express" is never counted as a pass. One of the 5, escalation through delegation, is attempted as a direct SQL insert of a child grant, because the HTTP surface only creates read grants.

Why a perfect score is not the headline. A suite that the implementation it was written alongside passes in full is exactly the suite a reader should distrust. So it is also run against filelayer-prerebuild: Filelayer's own example as it was before its delivery and authorization were rebuilt, on the same library. That version is breached 3 times: among the 21, a forged but well-formed caller id treated as real and a revoked download replayable from a cache, and among the other 5, user-uploaded HTML rendered on the authenticated read path. The suite finds real defects in Filelayer's own code, which is the best evidence we have that it is not shaped around it. It is still our suite. Independent attacks are welcome, as an issue or a pull request.

From install to a stored file

From npm install to the first stored file, using the program printed in the quickstart that ships in the package: 4 lines of application code, no step that needs a person, and no account, credential or dashboard. It takes a few seconds on a laptop: on the machine that generated these results it took 5.2 seconds, the median of 5 cold runs (linux-x64, 2 CPU, an empty npm cache each time). About half of that is the two npm install steps (2.4 seconds), which depend on the network more than on the package; the first run of the program took 2.7 seconds.

Where the alternatives are better

Each alternative's REPORT.md has this section in full. The short version:

What this does not measure

Disagreeing with a number

Every number comes from data in benchmark/. Remove a row from decisions.json, or change a rule in loc.manifest.json, run node benchmark/run.mjs again and you have your own figure. If you think an alternative was built badly, its directory says what it followed and where; an issue that shows the better version is the most useful thing you can send us.

Filelayer is Apache-2.0. The quickstart is at filelayer.dev/quickstart.