Reproducing a backend vulnerability without touching production
Thirteen findings, thirteen test files, thirteen test logs. That was the most consequential decision in the whole audit, and it had nothing to do with the vulnerabilities. When I started reading internxt/drive-server-wi
Thirteen findings, thirteen test files, thirteen test logs. That was the most consequential decision in the whole audit, and it had nothing to do with the vulnerabilities.
When I started reading internxt/drive-server-wip in October 2026, I made one rule before writing a single assertion: nothing in this project would touch a production system, a real account, or a network service I did not own. The repository is public. The backend is a NestJS application with Sequelize, PostgreSQL, Valkey, a Bridge service for storage credentials, SendGrid for mail, and a fairly large e2e test harness already in the tree. All of that can be pointed at loopback. So every finding would be reproduced against a local checkout of a pinned commit, with synthetic users and disposable services, or it would not be reproduced at all.
That constraint shaped everything else. A security report is only useful if a maintainer can run it. If reproducing a finding needs a real account, a production dataset, or access to infrastructure the maintainer does not have, the report becomes an anecdote. So each finding got its own self-contained proof of concept, its own log, source references pinned to the audited commit 7d7a8be2 from 28 October, and a hash of the archive. A maintainer could run C07 without reading C08.
The first thing to build was the runner:
set -euo pipefail
case_id=${2:-}
if [[ ! "$case_id" =~ ^C(0[1-9]|1[0-3])$ || ! -f "$source_file" ]]; then
if [[ ! -f package.json || ! -x ./node_modules/.bin/jest || ! -d test/helpers ]]; then
target="test/security-poc-${case_id,,}.e2e-spec.ts"
if [[ -e "$target" ]]; then
cp -- "$source_file" "$target"
trap 'rm -f -- "$target"' EXIT
export NODE_OPTIONS=--experimental-vm-modules
export NODE_ENV=test
export RDS_HOSTNAME=127.0.0.1
export RDS_PORT=55432
export RDS_DBNAME=drive_audit
export RDS_USERNAME=audit
export RDS_PASSWORD=local_only_audit_password
export REDIS_CONNECTION_STRING=redis://127.0.0.1:56379
export REDIS_JOBS_CONNECTION_STRING=redis://127.0.0.1:56379
export PCREATED_USERS_PASSWORD=local_only_precreated_password
export NOTIFICATIONS_API_ENABLED=false
export SENDGRID_MODE_SANDBOX=true
./node_modules/.bin/jest --config ./test/jest-e2e.json --runInBand \
--runTestsByPath "$target" --silent --forceExit
It takes a PoC source file and a case ID (C01 through C13). The first if rejects a bad ID or a missing file. The second refuses to run outside a checked-out repository with dependencies installed and a test/helpers directory. Then it refuses to overwrite an existing test file, copies the PoC to test/security-poc-<case>.e2e-spec.ts, and installs a trap that removes it again on EXIT. Every connection string is loopback: PostgreSQL on 55432 with TLS, Valkey on 56379. Every credential is synthetic and written into the report. NOTIFICATIONS_API_ENABLED=false and SENDGRID_MODE_SANDBOX=true exist so that no mail can leave the process even if a test path reaches the mailer by accident.
That trap line matters more than it looks. A PoC that leaves files behind changes the repository it claims to be testing. A PoC that overwrites an existing test can destroy evidence. A runner that happily executes against a non-loopback host turns a defensive test into something else entirely. These are small lines, and they are the difference between a reproducible report and a claim.
The installation step was equally deliberate, so that installing dependencies does not execute arbitrary package scripts or phone home, and thirteen separate cases never share database state:
npm ci --ignore-scripts --no-audit --no-fund
./node_modules/.bin/jest --config ./test/jest-e2e.json --runInBand \
--runTestsByPath "$target" --silent --forceExit
--runInBand because a leaked handle should not hang a report; --silent --forceExit because the log should be readable in one sitting.
Why HTTP-level e2e tests rather than unit tests against the service classes? Because two of the three most interesting findings were invisible at the unit level. C07's broken behaviour was a side effect that happened before the method threw; a mocked repository would have shown the delete and the 403 as two independent, "correct" facts. C08 was a timing property: a token blacklisted for 120 milliseconds and re-accepted 350 milliseconds later can only be observed by sending real requests against a real cache, with a clock in the test. The repository already had an e2e harness β createTestApp builds the actual Nest application with the actual modules and a mocked Bridge provider β so the honest reproduction used it:
export interface CreateTestAppOptions {
enableAuthGuard?: boolean;
enableValidationPipe?: boolean;
enableTransformInterceptor?: boolean;
enableExtendedQueryParser?: boolean;
}
export async function createTestApp(
options: CreateTestAppOptions = {},
): Promise<NestExpressApplication> {
const {
enableAuthGuard = true,
enableValidationPipe = true,
enableTransformInterceptor = true,
enableExtendedQueryParser = true,
} = options;
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
})
The application that comes up is not a stub. Real controllers, real guards, real Sequelize models against the disposable database, real Redis client against the disposable Valkey; only the Bridge, the external storage credential service, is mocked, because it would otherwise want to talk to infrastructure nobody should give a test. That decision matters for what a PoC can honestly claim. A mocked guard would have proven nothing about the guard. The point of running the whole stack locally was that every 403 and every 200 in the logs was produced by the same code that would produce it in production, with only the data and the network being synthetic.
Getting there was not free. The first PoC failed because a migration had not run against the disposable database; the second because the test configuration expected Valkey on a hostname that only exists inside the repository's docker-compose network, which is why the runner pins REDIS_CONNECTION_STRING to 127.0.0.1:56379 explicitly; the third because the mock Bridge provider was missing getLimit() and the application refused to finish booting. None of these failures said anything about the vulnerabilities. All of them had to be solved before a single finding could be demonstrated, and all of them produced changes that made the harness better rather than special-casing a single test. That is the actual work of building a reproduction, and it is invisible in the final one-pass log: the PoC that ships in the report is the fourth draft of a file whose first three drafts failed for reasons that had nothing to do with the bug.
One thing was missing on the audited commit. The mock Bridge provider has no getLimit(), but the application calls it during setup. I added it with a patch and documented it separately from every finding:
diff --git a/test/helpers/test-app.helper.ts b/test/helpers/test-app.helper.ts
index c721448..a099f94 100644
@@ -23,6 +23,10 @@ class MockBridgeService {
+ async getLimit() {
+ return 1_000_000_000;
+ }
async deleteFile() {
It changes test code only. It does not remediate a vulnerability. I wrote that sentence into all thirteen reports on purpose, because a reviewer should never have to wonder whether the PoC quietly fixed the bug it claims to demonstrate. A test-only compatibility shim that is clearly labelled is boring. An unlabelled one is a reason to distrust the whole package.
Each PoC repeated the boundary check at the top of its beforeAll:
if (process.env.RDS_HOSTNAME !== '127.0.0.1' || process.env.REDIS_CONNECTION_STRING?.includes('127.0.0.1') !== true) {
throw new Error('PoC requires loopback PostgreSQL and Redis');
app = await createTestApp();
let sharings: typeof SharingModel;
let invites: typeof SharingInviteModel;
let roles: typeof RoleModel;
let workspaces: typeof WorkspaceModel;
let workspaceInvites: typeof WorkspaceInviteModel;
let teams: typeof WorkspaceTeamModel;
let members: typeof WorkspaceUserModel;
let teamMembers: typeof WorkspaceTeamUserModel;
let preCreatedUsers: typeof PreCreatedUserModel;
let users: typeof UserModel;
beforeAll(async () => {
If RDS_HOSTNAME is not 127.0.0.1, or the Redis connection string does not point at loopback, the test throws before a single fixture is created. That guard is part of the evidence. It turns "no production system was touched" from a promise into a checked condition that a maintainer can read and verify. Synthetic users come from createTestUser, folders are created directly through the model, keys are literal strings like local-key, and the database is called drive_audit with a user named audit. Anyone reading the log can see there is no real data in it.
The reason for thirteen separate files rather than one suite was state. A shared suite accumulates it: one case leaves a user, a token, a sharing row, an invite, a workspace team behind, and the next case inherits that state. Then a passing test proves something about the previous test rather than about the vulnerability. Separate runs make each result attributable and each log short enough to read in a sitting. The cost is a lot of duplicated setup code β the same twenty imports, the same beforeAll, the same createTestUser calls appear in every file. That duplication is cheaper than ambiguity when the report is handed to someone who has never seen the codebase.
It also made the reports easier to write. Each one could say: here is the file, here is the commit, here is the command, here is the observed result, here is what was not tested. For the C07 case, the observed result was three assertions:
expect(res.status).toBe(403);
expect(await sharings.count({ where: { itemId: folder.uuid, type: 'private' } })).toBe(0);
expect(await invites.count({ where: { itemId: folder.uuid } })).toBe(0);
For C08 it was 200, 401, 200 after a 350-millisecond wait. For C03 it was 200 and a missing row. Nothing in the reports claims an impact that the test did not measure.
The structure of each report followed from that: a summary stating the observed behaviour and the revision it was reproduced on; a details section with affected code, observed behaviour, suggested remediation, and an explicit scope paragraph; the PoC source and the test-only patch, clearly separated; the runner settings; the observed local result; and a limitations section. The same shape thirteen times, so a maintainer reading the eighth report already knows where everything is. Repetition in the wrapper is not a flaw; it is what makes the package skimmable.
The hash of the archive was the last piece, and it exists for an unglamorous reason. A report of this size travels as a zip, and zips get re-downloaded, forwarded, and rebuilt. A SHA-256 on the cover email means the person who eventually reads it can confirm they are reading what I sent, not a version that lost a file or gained an edit somewhere in the chain. It costs one line and closes a whole class of "are we looking at the same thing" arguments before they start.
None of this was fast. Reading the sharing module, the auth module and the workspace module properly took the better part of two weekends; building and debugging the harness took another; writing thirteen reports that each stand on their own took longer than finding the bugs. That ratio is normal and worth saying out loud, because the visible part of security research is the finding and the invisible part is everything that makes the finding believable. Anyone can claim a bug exists. The work is in making the claim cheap to verify.
The hardest part of the whole audit was not the code. It was writing down what a passing local test does not prove. A PoC establishes that a code path behaved as described on the checked commit. It says nothing about production reachability, deployment topology, log access, network position, certificate distribution, or whether the behaviour was ever exploited. Those answers belong to the maintainer, and no amount of local testing can produce them. Every report carried that boundary once, at the top, instead of a Severity section padded with speculation. That discipline is also why the reports went out privately: the tests were built to be reproducible, not to be published before a fix existed.
There is a tension in that discipline worth naming. A PoC that is too cautious proves nothing and wastes everyone's time; a PoC that reaches too far proves things that were never tested. The line I settled on: reproduce the code path exactly as a caller would reach it, claim exactly what the log shows, and stop there. No "an attacker could pivot to", no hypothetical chains, no severity theatre. The dryness is deliberate. A report that says "these three assertions failed in this order on this commit" is one a maintainer can act on in an afternoon, and one I can defend line by line six weeks later against every question of whether the finding was real.
On 28 October the archive went to [email protected] and [email protected]: thirteen findings, thirteen PoCs, thirteen test logs, source references, a hash. Getting a confidential channel to send it to had taken eight days and an escalation to a national CERT. The technical work, by contrast, had gone almost exactly to plan. That asymmetry is the part of this story I still find strange. Building a harness that cannot hurt anyone took a weekend of careful, boring decisions. Getting an acknowledgement from the company took six weeks.
If you take one thing from this, take the trap line. A reproduction that cleans up after itself, refuses to run in the wrong environment, and states its own limits is worth more than a dramatic proof of concept. The rest of the audit β the disclosure timeline, the advisories that were published, the ones that were closed, the ones still in triage β is written up in the timeline post. This post is only about the part that worked.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.