CVE-2022-31051: Exposure of Sensitive Information to an Unauthorized Actor (CWE-200)
value: semantic-release is an open source npm package for automated version management and package publishing. In affected versions secrets that would normally be masked by semantic-release can be accidentally disclosed if they contain characters that are excluded from uri encoding by `encodeURI`. Occurrence is further limited to execution contexts where push access to the related repository is not available without modifying the repository url to inject credentials. Users are advised to upgrade. Users unable to upgrade should ensure that secrets that do not contain characters that are excluded from encoding with `encodeURI` when included in a URL are already masked properly.
CWE description: The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
CVSS v3 base score: 7.5
Published: 2022-06-09T20:15Z
Repository: https://github.com/semantic-release/semantic-release
Language: JavaScript
Files changed: index.js, test/index.test.js
Commit date: 2022-06-08 21:09:47 -0500
Commit message: fix(log-repo): use the original form of the repo url to remove the need to mask credentials (#2459)

fixes #2449
Diff: diff --git a/index.js b/index.js
index 8456ad5..b5b67a6 100644
--- a/index.js
+++ b/index.js
@@ -73,11 +73,11 @@ async function run(context, plugins) {
     );
     return false;
   }
 
   logger[options.dryRun ? 'warn' : 'success'](
-    `Run automated release from branch ${ciBranch} on repository ${options.repositoryUrl}${
+    `Run automated release from branch ${ciBranch} on repository ${options.originalRepositoryURL}${
       options.dryRun ? ' in dry-run mode' : ''
     }`
   );
 
   try {
@@ -261,10 +261,11 @@ module.exports = async (cliOptions = {}, {cwd = process.cwd(), env = process.env
   };
   context.logger = getLogger(context);
   context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
   try {
     const {plugins, options} = await getConfig(context, cliOptions);
+    options.originalRepositoryURL = options.repositoryUrl;
     context.options = options;
     try {
       const result = await run(context, plugins);
       unhook();
       return result;
diff --git a/test/index.test.js b/test/index.test.js
index d2533c4..2f1b09b 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -88,10 +88,11 @@ test('Plugins are called with expected values', async (t) => {
   const success = stub().resolves();
   const env = {};
   const config = {
     branches: [{name: 'master'}, {name: 'next'}],
     repositoryUrl,
+    originalRepositoryURL: repositoryUrl,
     globalOpt: 'global',
     tagFormat: `v\${version}`,
   };
   const branches = [
     {
@@ -925,11 +926,16 @@ test('Log all "verifyConditions" errors', async (t) => {
 
   const error1 = new Error('error 1');
   const error2 = new SemanticReleaseError('error 2', 'ERR2');
   const error3 = new SemanticReleaseError('error 3', 'ERR3');
   const fail = stub().resolves();
-  const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
+  const config = {
+    branches: [{name: 'master'}],
+    repositoryUrl,
+    originalRepositoryURL: repositoryUrl,
+    tagFormat: `v\${version}`,
+  };
   const options = {
     ...config,
     plugins: false,
     verifyConditions: [stub().rejects(new AggregateError([error1, error2])), stub().rejects(error3)],
     fail,

Vulnerable code:     `Run automated release from branch ${ciBranch} on repository ${options.repositoryUrl}${
  const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
Fixed code:     `Run automated release from branch ${ciBranch} on repository ${options.originalRepositoryURL}${
    options.originalRepositoryURL = options.repositoryUrl;
    originalRepositoryURL: repositoryUrl,
  const config = {
    branches: [{name: 'master'}],
    repositoryUrl,
    originalRepositoryURL: repositoryUrl,
    tagFormat: `v\${version}`,
  };