Skip to content

CVE-2007-4559 Patch - #4499

Merged
hawflau merged 9 commits into
aws:developfrom
TrellixVulnTeam:develop
Jan 4, 2023
Merged

CVE-2007-4559 Patch#4499
hawflau merged 9 commits into
aws:developfrom
TrellixVulnTeam:develop

Conversation

@TrellixVulnTeam

Copy link
Copy Markdown
Contributor

Patching CVE-2007-4559

Hi, we are security researchers from the Advanced Research Center at Trellix. We have began a campaign to patch a widespread bug named CVE-2007-4559. CVE-2007-4559 is a 15 year old bug in the Python tarfile package. By using extract() or extractall() on a tarfile object without sanitizing input, a maliciously crafted .tar file could perform a directory path traversal attack. We found at least one unsantized extractall() in your codebase and are providing a patch for you via pull request. The patch essentially checks to see if all tarfile members will be extracted safely and throws an exception otherwise. We encourage you to use this patch or your own solution to secure against CVE-2007-4559. Further technical information about the vulnerability can be found in this blog.

If you have further questions you may contact us through this projects lead researcher Kasimir Schulz.

@TrellixVulnTeam
TrellixVulnTeam requested a review from a team as a code owner December 18, 2022 16:59
@github-actions github-actions Bot added area/local/invoke sam local invoke command area/local/start-api sam local start-api command area/local/start-invoke pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Dec 18, 2022
@qingchm

qingchm commented Dec 19, 2022

Copy link
Copy Markdown
Contributor

@TrellixVulnTeam Thanks for opening this pull request! Please address the corresponding make pr failure, which should be easily fixed by running make black! In this way we can prioritize this and get this into our code ASAP!

@qingchm qingchm removed the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Dec 20, 2022
Comment thread samcli/local/docker/container.py Outdated
with tarfile.open(fileobj=fp, mode="r") as tar:
tar.extractall(path=to_host_path)

def is_within_directory(directory, target):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to move these inner functions to a utility module, and to add unit test cases for them.

@hawflau
hawflau dismissed moelasmar’s stale review January 4, 2023 17:44

addressed comment

@hawflau
hawflau merged commit 40bd90a into aws:develop Jan 4, 2023
hawflau added a commit that referenced this pull request Jan 4, 2023
hawflau added a commit that referenced this pull request Jan 4, 2023
hnnasit added a commit that referenced this pull request Jan 5, 2023
mildaniel pushed a commit that referenced this pull request Jan 10, 2023
* support lists of source_path dicts

* add unit tests for source_path is specified as a list of dicts

* fix: update pyopenssl dependency (#4528)

* chore(deps): bump setuptools from 54.2.0 to 65.5.1 in /requirements (#4518)

Bumps [setuptools](https://github.com/pypa/setuptools) from 54.2.0 to 65.5.1.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/CHANGES.rst)
- [Commits](pypa/setuptools@v54.2.0...v65.5.1)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump version to 1.68.0 (#4532)

Co-authored-by: Lau <lauwing@f8ffc25e8e59.ant.amazon.com>

* CVE-2007-4559 Patch (#4499)

* Adding tarfile member sanitization to extractall()

* fix formatting issues

* Refactored extract_tarfile functions and added unit/functional tests

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: hnnasit <84355507+hnnasit@users.noreply.github.com>
Co-authored-by: Haresh Nasit <hnnasit@amazon.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>

* chore: Update development guide to include information on dependency updates (#4476)

* Add in instructions on updating SAMCLI dependencies

* Update the command to be run to write to reproducible linux

* Highlight content using separate sections for requirement files

* Fix typos and reword for better readability

* Update development guide text

* Revert "CVE-2007-4559 Patch (#4499)" (#4535)

This reverts commit 40bd90a.

* chore: change license badge in readme to display GH license (#4538)

* chore: update readme with pypi license

* use gh rather than pypi

* formatting only changes made by terraform fmt command

* add intergration tests

* Re-arrange order of if statements to remove recursion

* remove print statement that was leftover from development

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Lau <lauwing@f8ffc25e8e59.ant.amazon.com>
Co-authored-by: TrellixVulnTeam <112716341+TrellixVulnTeam@users.noreply.github.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: hnnasit <84355507+hnnasit@users.noreply.github.com>
Co-authored-by: Haresh Nasit <hnnasit@amazon.com>
Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>
hnnasit added a commit that referenced this pull request Jan 10, 2023
* Revert "Revert "CVE-2007-4559 Patch (#4499)" (#4535)"

This reverts commit 1065683.

* Changed extract_tarfile input tarfile_path to str file path

* Added type annotation for copy function

Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
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.

7 participants