CVE-2021-32638 (JavaScript, published 2021-05-25T17:15Z)
Description: value: Github's CodeQL action is provided to run CodeQL-based code scanning on non-GitHub CI/CD systems and requires a GitHub access token to connect to a GitHub repository. The runner and its documentation previously suggested passing the GitHub token as a command-line parameter to the process instead of reading it from a file, standard input, or an environment variable. This approach made the token visible to other processes on the same machine, for example in the output of the `ps` command. If the CI system publicly exposes the output of `ps`, for example by logging the output, then the GitHub access token can be exposed beyond the scope intended. Users of the CodeQL runner on 3rd-party systems, who are passing a GitHub token via the `--github-auth` flag, are affected. This applies to both GitHub.com and GitHub Enterprise users. Users of the CodeQL Action on GitHub Actions are not affected. The `--github-auth` flag is now considered insecure and deprecated. The undocumented `--external-repository-token` flag has been removed. To securely provide a GitHub access token to the CodeQL runner, users should **do one of the following instead**: Use the `--github-auth-stdin` flag and pass the token on the command line via standard input OR set the `GITHUB_TOKEN` environment variable to contain the token, then call the command without passing in the token. The old flag remains present for backwards compatibility with existing workflows. If the user tries to specify an access token using the `--github-auth` flag, there is a deprecation warning printed to the terminal that directs the user to one of the above options. All CodeQL runner releases codeql-bundle-20210304 onwards contain the patches. We recommend updating to a recent version of the CodeQL runner, storing a token in your CI system's secret storage mechanism, and passing the token to the CodeQL runner using `--github-auth-stdin` or the `GITHUB_TOKEN` environment variable. If still using the old flag, ensure that process output, such as from `ps`, is not persisted in CI logs.
Severity: LOW (CVSS v3 base score: 4.4)
Weakness: CWE-200 \u2014 Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
Repository: https://github.com/github/codeql-action
Files changed:
lib/runner.js
lib/runner.js.map
lib/util.js
lib/util.js.map
lib/util.test.js
lib/util.test.js.map
src/runner.ts
src/util.test.ts
src/util.ts
Commit message: Add capability to specify auth from env var or stdin

This commit adds two new ways of specifying GitHub auth:

1. from the GITHUB_TOKEN environment variable
2. from standard input

This commit does not include any documentation changes and the
descriptions of new command line options will need to be tweaked.


Vulnerable code:
    .requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
            auth: cmd.githubAuth,
    .requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
            auth: cmd.githubAuth,
    .requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
        auth: cmd.githubAuth,
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,yCAAoC;AAEpC,uCAAuC;AACvC,2CAAuE;AACvE,qCAA6C;AAC7C,iDAAmD;AACnD,iCAA8E;AAC9E,2CAAsD;AACtD,uCAA4C;AAC5C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAOgB;AAEhB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEzB,SAAS,UAAU,CAAC,SAA6B;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;IACvE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KAC5C;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAC,SAA6B;IAChD,MAAM,QAAQ,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,qBAAqB,CAAC,CAAC;IAC7E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KAC7C;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,qBAA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IAAI,CAAC,CAAC;IAE/C,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC;QACrC,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,yBAAyB;KAC/B,CAAC,CAAC;IACH,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IAEnE,wBAAwB,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC;QACvC,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,sCAAsC;KAC5C,CAAC,CAAC;IACH,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IAErD,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC;QACrC,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,yBAAyB;KAC/B,CAAC,CAAC;IACH,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
  .requiredOption(
    "GitHub Apps token or personal access token. (Required)"
        auth: cmd.githubAuth,
  .requiredOption(
    "GitHub Apps token or personal access token. (Required)"
        auth: cmd.githubAuth,
  .requiredOption(
    "GitHub Apps token or personal access token. (Required)"
      auth: cmd.githubAuth,
import test from "ava";
import { getRunnerLogger } from "./logging";

Fixed code:
    .option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
    .option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
        const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
            auth,
    .option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
    .option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
        const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
            auth,
    .option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
    .option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
    const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
        auth,
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,yCAAoC;AAEpC,uCAAuC;AACvC,2CAAuE;AACvE,qCAA6C;AAC7C,iDAAmD;AACnD,iCAA8E;AAC9E,2CAAsD;AACtD,uCAA4C;AAC5C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAQgB;AAEhB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEzB,SAAS,UAAU,CAAC,SAA6B;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;IACvE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KAC5C;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAC,SAA6B;IAChD,MAAM,QAAQ,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,qBAAqB,CAAC,C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CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACtB;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
/**
 * Retrieves the github auth token for use with the runner. There are
 * three possible locations for the token:
 *
 * 1. from the cli (considered insecure)
 * 2. from stdin
 * 3. from the GITHUB_TOKEN environment variable
 *
 * If both 1 & 2 are specified, then an error is thrown.
 * If 1 & 3 or 2 & 3 are specified, then the environment variable is ignored.
 *
 * @param githubAuth a github app token or PAT
 * @param fromStdIn read the github app token or PAT from stdin up to, but excluding the first whitespace
 * @param readable the readable stream to use for getting the token (defaults to stdin)
 *
 * @return a promise resolving to the auth token.
 */
async function getGitHubAuth(logger, githubAuth, fromStdIn, readable = process.stdin) {
    if (githubAuth && fromStdIn) {
        throw new Error("Cannot specify both `--github-auth` and `--github-auth-stdin`. Please use `--github-auth-stdin`, which is more secure.");
    }
    if (githubAuth) {
        logger.warning("Using `--github-auth` via the CLI is insecure. Use `--github-auth-stdin` instead.");
        return githubAuth;
    }
    if (fromStdIn) {
        return new Promise((resolve, reject) => {
            let token = "";
            readable.on("data", (data) => {
                token += data.toString("utf8");
            });
            readable.on("end", () => {
                token = token.split(/\s+/)[0].trim();
                if (token) {
                    resolve(token);
                }
                else {
                    reject(new Error("Standard input is empty"));
                }
            });
            readable.on("error", (err) => {
                reject(err);
            });
        });
    }
    if (process.env.GITHUB_TOKEN) {
        return process.env.GITHUB_TOKEN;
    }
    throw new Error("No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input.");
}
exports.getGitHubAuth = getGitHubAuth;
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;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AAC,CAAC,IAAI,EAAE,CAAC;gBACrC,IAAI,KAAK,EAAE;oBACT,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChB;qBAAM;oBACL,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;iBAC9C;YACH,CAAC,CAAC,CAAC;YACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC3B,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;QAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;KACjC;IAED,MAAM,IAAI,KAAK,CACb,uMAAuM,CACxM,CAAC;AACJ,CAAC;AA9CD,sCA8CC"}
const stream = __importStar(require("stream"));
ava_1.default("getGitHubAuth", async (t) => {
    const msgs = [];
    const mockLogger = {
        warning: (msg) => msgs.push(msg),
    };
    // eslint-disable-next-line @typescript-eslint/no-floating-promises
    t.throwsAsync(async () => util.getGitHubAuth(mockLogger, "abc", true));
    process.env.GITHUB_TOKEN = "123";
    t.is("123", await util.getGitHubAuth(mockLogger, undefined, undefined));
    t.is(msgs.length, 0);
    t.is("abc", await util.getGitHubAuth(mockLogger, "abc", undefined));
    t.is(msgs.length, 1); // warning expected
    msgs.length = 0;
    await mockStdInForAuth(t, mockLogger, "def", "def");
    await mockStdInForAuth(t, mockLogger, "def", "", "def");
    await mockStdInForAuth(t, mockLogger, "def", "def\n some extra garbage", "ghi");
    await mockStdInForAuth(t, mockLogger, "defghi", "def", "ghi\n123");
    await mockStdInForAuthExpectError(t, mockLogger, "");
    await mockStdInForAuthExpectError(t, mockLogger, "", " ", "abc");
    await mockStdInForAuthExpectError(t, mockLogger, "  def\n some extra garbage", "ghi");
    t.is(msgs.length, 0);
});
async function mockStdInForAuth(t, mockLogger, expected, ...text) {
    const stdin = stream.Readable.from(text);
    t.is(expected, await util.getGitHubAuth(mockLogger, undefined, true, stdin));
}
async function mockStdInForAuthExpectError(t, mockLogger, ...text) {
    const stdin = stream.Readable.from(text);
    await t.throwsAsync(async () => util.getGitHubAuth(mockLogger, undefined, true, stdin));
}
{"version":3,"file":"util.test.js","sourceRoot":"","sources":["../src/util.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyB;AACzB,uCAAyB;AACzB,+CAAiC;AAEjC,wDAA0C;AAC1C,8CAA6C;AAC7C,kDAA0B;AAE1B,kDAAoC;AACpC,uCAAoD;AACpD,mDAA6C;AAC7C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;IACzB,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAC3B,GAAG,SAAS,mCAAmC,EAC/C,MAAM,CACP,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,+BAA+B,EAAE,QAAQ,CAAC,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,sDAAsD,EAAE,CAAC,CAAC,EAAE,EAAE;IACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IAE3D,MAAM,KAAK,GAAG;QACZ,CAAC,SAAS,EAAE,SAAS,QAAQ,GAAG,GAAG,EAAE,CAAC;QACtC,CAAC,EAAE,EAAE,SAAS,QAAQ,GAAG,GAAG,EAAE,CAAC;QAC/B,CAAC,KAAK,EAAE,WAAW,CAAC;KACrB,CAAC;IAEF,KAAK,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,KAAK,EAAE;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,a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AEjB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAQ,CAAC;IAChD,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,KAAK,UAAU,2BAA2B,CACxC,CAA4B,EAC5B,UAAkB,EAClB,GAAG,IAAc;IAEjB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAQ,CAAC;IAChD,MAAM,CAAC,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAC7B,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CACvD,CAAC;AACJ,CAAC"}
  getGitHubAuth,
  githubAuthStdin: boolean;
  .option(
    "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead."
  )
  .option(
    "--github-auth-stdin",
    "Read GitHub Apps token or personal access token from stdin."
      const auth = await getGitHubAuth(
        logger,
        cmd.githubAuth,
        cmd.githubAuthStdin
      );

        auth,
  githubAuthStdin: boolean;
  .option(
    "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead."
  )
  .option(
    "--github-auth-stdin",
    "Read GitHub Apps token or personal access token from stdin."
      const auth = await getGitHubAuth(
        logger,
        cmd.githubAuth,
        cmd.githubAuthStdin
      );

        auth,
  githubAuthStdin: boolean;
  .option(
    "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead."
  )
  .option(
    "--github-auth-stdin",
    "Read GitHub Apps token or personal access token from stdin."
    const auth = await getGitHubAuth(
      logger,
      cmd.githubAuth,
      cmd.githubAuthStdin
    );
      auth,
import * as stream from "stream";
import test, { ExecutionContext } from "ava";
import { getRunnerLogger, Logger } from "./logging";

test("getGitHubAuth", async (t) => {
  const msgs: string[] = [];
  const mockLogger = ({
    warning: (msg: string) => msgs.push(msg),
  } as unknown) as Logger;

  // eslint-disable-next-line @typescript-eslint/no-floating-promises
  t.throwsAsync(async () => util.getGitHubAuth(mockLogger, "abc", true));

  process.env.GITHUB_TOKEN = "123";
  t.is("123", await util.getGitHubAuth(mockLogger, undefined, undefined));
  t.is(msgs.length, 0);
  t.is("abc", await util.getGitHubAuth(mockLogger, "abc", undefined));
  t.is(msgs.length, 1); // warning expected

  msgs.length = 0;
  await mockStdInForAuth(t, mockLogger, "def", "def");
  await mockStdInForAuth(t, mockLogger, "def", "", "def");
  await mockStdInForAuth(
    t,
    mockLogger,
    "def",
    "def\n some extra garbage",
    "ghi"
  );
  await mockStdInForAuth(t, mockLogger, "defghi", "def", "ghi\n123");

  await mockStdInForAuthExpectError(t, mockLogger, "");
  await mockStdInForAuthExpectError(t, mockLogger, "", " ", "abc");
  await mockStdInForAuthExpectError(
    t,
    mockLogger,
    "  def\n some extra garbage",
    "ghi"
  );
  t.is(msgs.length, 0);
});

async function mockStdInForAuth(
  t: ExecutionContext<any>,
  mockLogger: Logger,
  expected: string,
  ...text: string[]
) {
  const stdin = stream.Readable.from(text) as any;
  t.is(expected, await util.getGitHubAuth(mockLogger, undefined, true, stdin));
}

async function mockStdInForAuthExpectError(
  t: ExecutionContext<unknown>,
  mockLogger: Logger,
  ...text: string[]
) {
  const stdin = stream.Readable.from(text) as any;
  await t.throwsAsync(async () =>
    util.getGitHubAuth(mockLogger, undefined, true, stdin)
  );
}
import { Readable } from "stream";

/**
 * Retrieves the github auth token for use with the runner. There are
 * three possible locations for the token:
 *
 * 1. from the cli (considered insecure)
 * 2. from stdin
 * 3. from the GITHUB_TOKEN environment variable
 *
 * If both 1 & 2 are specified, then an error is thrown.
 * If 1 & 3 or 2 & 3 are specified, then the environment variable is ignored.
 *
 * @param githubAuth a github app token or PAT
 * @param fromStdIn read the github app token or PAT from stdin up to, but excluding the first whitespace
 * @param readable the readable stream to use for getting the token (defaults to stdin)
 *
 * @return a promise resolving to the auth token.
 */
export async function getGitHubAuth(
  logger: Logger,
  githubAuth: string | undefined,
  fromStdIn: boolean | undefined,
  readable = process.stdin as Readable
): Promise<string> {
  if (githubAuth && fromStdIn) {
    throw new Error(
      "Cannot specify both `--github-auth` and `--github-auth-stdin`. Please use `--github-auth-stdin`, which is more secure."
    );
  }

  if (githubAuth) {
    logger.warning(
      "Using `--github-auth` via the CLI is insecure. Use `--github-auth-stdin` instead."
    );
    return githubAuth;
  }

  if (fromStdIn) {
    return new Promise((resolve, reject) => {
      let token = "";
      readable.on("data", (data) => {
        token += data.toString("utf8");
      });
      readable.on("end", () => {
        token = token.split(/\s+/)[0].trim();
        if (token) {
          resolve(token);
        } else {
          reject(new Error("Standard input is empty"));
        }
      });
      readable.on("error", (err) => {
        reject(err);
      });
    });
  }

  if (process.env.GITHUB_TOKEN) {
    return process.env.GITHUB_TOKEN;
  }

  throw new Error(
    "No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input."
  );
}