Skip to content

Fix: sanitize archive extraction paths in RPA.Archive (zip slip) #1340

Description

@mikahanninen

Summary

Fix the zip-slip / path-traversal vulnerability reported in #1339.

Archive.extract_archive() in packages/main/src/RPA/Archive.py calls zipfile.ZipFile.extractall() and tarfile.TarFile.extractall() on archive members without validating that resolved member paths stay within the target extraction directory. A crafted archive entry (e.g. ../../evil.py) can write files outside the intended path.

Location

packages/main/src/RPA/Archive.py, extract_archive() (currently lines ~374-386).

Fix approach

  • Before extracting, resolve each member's destination path against the target directory and reject/skip entries that would escape it (classic Zip Slip guard), for both the zipfile and tarfile branches.
  • For tarfile, additionally pass filter="data" (Python 3.12+ safe extraction filter) where available.
  • Add a regression test using a crafted archive with a ../ path traversal entry, asserting extraction is rejected/contained.

Related

Sub-issue of #1339.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions