Skip to content

Commit 790501b

Browse files
committed
Allow auth tokens to be set by $HTK_SERVER_TOKEN
This tightens token auth further. Using --token, another process on your machine could in theory look at process command line to get the auth token, and use that to access the API to increase its privileges. There's no known viable attacks even given that access, and this would require a malicious process to already be running on your machine, but it's good to be able to block that regardless.
1 parent 280ede4 commit 790501b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/commands/start.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
type ErrorTrackingModule = typeof import('../error-tracking');
33
type IndexTypeModule = typeof import('../index');
44

5+
// We accept auth tokens from the environment, allowing a token to be
6+
// set without exposing it in the command line arguments.
7+
const envToken = process.env.HTK_SERVER_TOKEN;
8+
delete process.env.HTK_SERVER_TOKEN; // Don't let anything else see this
9+
510
import * as path from 'path';
611
import { promises as fs } from 'fs'
712
import * as semver from 'semver';
@@ -48,7 +53,7 @@ class HttpToolkitServer extends Command {
4853

4954
await runHTK({
5055
configPath: flags.config,
51-
authToken: flags.token
56+
authToken: envToken || flags.token
5257
}).catch(async (error) => {
5358
await reportError(error);
5459
throw error;

0 commit comments

Comments
 (0)