Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Mar 7, 2022

WhiteSource Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
tar 4.4.6 -> 4.4.15 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2021-32804

Impact

Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution

node-tar aims to prevent extraction of absolute file paths by turning absolute paths into relative paths when the preservePaths flag is not set to true. This is achieved by stripping the absolute path root from any absolute file paths contained in a tar file. For example /home/user/.bashrc would turn into home/user/.bashrc.

This logic was insufficient when file paths contained repeated path roots such as ////home/user/.bashrc. node-tar would only strip a single path root from such paths. When given an absolute file path with repeating path roots, the resulting path (e.g. ///home/user/.bashrc) would still resolve to an absolute path, thus allowing arbitrary file creation and overwrite.

Patches

3.2.2 || 4.4.14 || 5.0.6 || 6.1.1

NOTE: an adjacent issue CVE-2021-32803 affects this release level. Please ensure you update to the latest patch levels that address CVE-2021-32803 as well if this adjacent issue affects your node-tar use case.

Workarounds

Users may work around this vulnerability without upgrading by creating a custom onentry method which sanitizes the entry.path or a filter method which removes entries with absolute paths.

const path = require('path')
const tar = require('tar')

tar.x({
  file: 'archive.tgz',
  // either add this function...
  onentry: (entry) => {
    if (path.isAbsolute(entry.path)) {
      entry.path = sanitizeAbsolutePathSomehow(entry.path)
      entry.absolute = path.resolve(entry.path)
    }
  },

  // or this one
  filter: (file, entry) => {
    if (path.isAbsolute(entry.path)) {
      return false
    } else {
      return true
    }
  }
})

Users are encouraged to upgrade to the latest patch versions, rather than attempt to sanitize tar input themselves.

CVE-2021-32803

Impact

Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution

node-tar aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.

This logic was insufficient when extracting tar files that contained both a directory and a symlink with the same name as the directory. This order of operations resulted in the directory being created and added to the node-tar directory cache. When a directory is present in the directory cache, subsequent calls to mkdir for that directory are skipped. However, this is also where node-tar checks for symlinks occur.

By first creating a directory, and then replacing that directory with a symlink, it was thus possible to bypass node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and subsequently extracting arbitrary files into that location, thus allowing arbitrary file creation and overwrite.

This issue was addressed in releases 3.2.3, 4.4.15, 5.0.7 and 6.1.2.

Patches

3.2.3 || 4.4.15 || 5.0.7 || 6.1.2

Workarounds

Users may work around this vulnerability without upgrading by creating a custom filter method which prevents the extraction of symbolic links.

const tar = require('tar')

tar.x({
  file: 'archive.tgz',
  filter: (file, entry) => {
    if (entry.type === 'SymbolicLink') {
      return false
    } else {
      return true
    }
  }
})

Users are encouraged to upgrade to the latest patch versions, rather than attempt to sanitize tar input themselves.


Release Notes

npm/node-tar

v4.4.15

Compare Source

v4.4.14

Compare Source

v4.4.13

Compare Source

v4.4.12

Compare Source

v4.4.11

Compare Source

v4.4.10

Compare Source

v4.4.9

Compare Source

v4.4.8

Compare Source

v4.4.7

Compare Source


Configuration

📅 Schedule: "" (UTC).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, click this checkbox.

This PR has been generated by WhiteSource Renovate. View repository job log here.

@renovate renovate bot added the chore label Mar 7, 2022
@renovate renovate bot force-pushed the renovate/npm-tar-vulnerability branch 9 times, most recently from 4f3e44e to 92053eb Compare March 7, 2022 20:44
@renovate renovate bot changed the title fix(deps): update dependency tar to v4.4.15 [security] fix(deps): update dependency tar to v4.4.15 [security] - autoclosed Apr 27, 2022
@renovate renovate bot closed this Apr 27, 2022
@renovate renovate bot deleted the renovate/npm-tar-vulnerability branch April 27, 2022 12:04
@renovate renovate bot changed the title fix(deps): update dependency tar to v4.4.15 [security] - autoclosed fix(deps): update dependency tar to v4.4.15 [security] Apr 27, 2022
@renovate renovate bot reopened this Apr 27, 2022
@renovate renovate bot restored the renovate/npm-tar-vulnerability branch April 27, 2022 14:38
@renovate renovate bot changed the title fix(deps): update dependency tar to v4.4.15 [security] fix(deps): update dependency tar to v4.4.15 [security] - autoclosed Apr 27, 2022
@renovate renovate bot closed this Apr 27, 2022
@renovate renovate bot deleted the renovate/npm-tar-vulnerability branch April 27, 2022 17:12
@renovate renovate bot changed the title fix(deps): update dependency tar to v4.4.15 [security] - autoclosed fix(deps): update dependency tar to v4.4.15 [security] Apr 27, 2022
@renovate renovate bot reopened this Apr 27, 2022
@renovate renovate bot restored the renovate/npm-tar-vulnerability branch April 27, 2022 19:42
@renovate renovate bot force-pushed the renovate/npm-tar-vulnerability branch 2 times, most recently from dc54bd6 to ce04fb8 Compare April 28, 2022 01:06
@renovate renovate bot force-pushed the renovate/npm-tar-vulnerability branch from ce04fb8 to 7ae2e9d Compare April 28, 2022 01:19
@renovate renovate bot merged commit ede960c into master Apr 28, 2022
@renovate renovate bot deleted the renovate/npm-tar-vulnerability branch April 28, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants