fix(worker): chmod materialized env file to 0600 even when it pre-exists
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
||||
import { chmod, mkdir, rm, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import { assertContainedRealPath } from './path-containment';
|
||||
@@ -24,6 +24,9 @@ export const writeMaterializedEnv = async (
|
||||
});
|
||||
await mkdir(path.dirname(envPath), { recursive: true });
|
||||
await writeFile(envPath, formatMaterializedEnv(secrets), { mode: 0o600 });
|
||||
// writeFile's mode only applies on create; chmod unconditionally tightens an
|
||||
// already-existing (possibly 0644) file so plaintext secrets never leak.
|
||||
await chmod(envPath, 0o600);
|
||||
return envPath;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user