Summary
AGL app-framework-main up to 17.1.12 is vulnerable to a Zip Slip style path traversal during widget installation, where ZIP entry names are insufficiently validated and can escape the intended working directory.
Because files are extracted before signature verification and error cleanup only removes the temporary directory, an attacker can write arbitrary files anywhere on the filesystem that persist even when signature checks fail.
Affected context
This vulnerability appears in the AGL app-framework-main widget installation flow, specifically in ZIP-based widget packages processed by the platform.
It affects deployments where:
- Widgets are installed from ZIP archives using the vulnerable installer logic
- The installer relies on
is_valid_filenamefor entry validation but does not block..or other traversal dot notation - The
zreadextraction is performed into a temporary working directory prior to signature verification
The risk is elevated in environments where widget packages come from semi-trusted or remotely supplied sources, such as app stores, OTA mechanisms, or user-provided bundles.
Exploit preconditions
- Attack surface: Widget installation mechanism that accepts ZIP-based widget packages.
- Required access: Ability to supply or control a widget ZIP file processed by AGL app-framework-main (e.g., app store submission, USB/OTA package upload, or other installation interfaces).
- Trigger point: Installation of a malicious widget, during which the ZIP entries are extracted with
zreadbefore signature verification ininstall_widget. - Why exploitation is possible:
is_valid_filenameinwgtpkg-zip.conly blocks absolute paths and does not reject../or other dot notation traversal sequences.zreadusesopenat(workdirfd, filename, O_CREAT)which resolves dot sequences relative to the working directory, allowing escape to parent directories (Zip Slip).- Signature verification (
check_all_signatures) occurs after extraction, so malicious files are already written by the time authenticity is checked. - On verification failure, cleanup (
remove_workdir) only removes files inside the temporary working directory; traversed files outside are not removed and therefore persist.
Why this happens
The underlying issue is a combination of incomplete path validation (CWE-22) and a time-of-check time-of-use (TOCTOU) ordering flaw (CWE-367) in the widget installation flow.
At the path handling level, the is_valid_filename function attempts to validate filenames but only rejects absolute paths, neglecting to check for relative traversal constructs such as ../ or ./../. As a result, user-controlled ZIP entry names can escape the intended extraction directory when passed to openat, a classic Zip Slip pattern where archive contents are written outside the target directory hierarchy.
At the control-flow level, install_widget extracts the ZIP contents via zread before invoking check_all_signatures. This creates a TOCTOU scenario: the trust check (signature verification) occurs after the use of untrusted data (file extraction). When signature verification later fails, cleanup logic only targets the temporary working directory, not the unintended filesystem locations already modified via path traversal. This sequence effectively decouples security validation from its intended protection boundary, allowing untrusted content to make persistent changes before being rejected.
Potential impact
- Arbitrary file creation or overwrite in directories outside the intended temporary work directory.
- Placement of files in sensitive paths that may influence system behavior (e.g., configuration files, scripts, or service definitions), depending on platform layout and permissions.
- Potential privilege escalation if overwritten files are executed or interpreted by more privileged components of the system.
- Persistence of malicious artifacts on the device even when widget signature verification fails.
- Facilitation of further attacks, such as backdoored applications, tampered system configuration, or sabotage of other applications.
General mitigation guidance
Effective mitigation focuses on strengthening path handling and aligning security checks with data use:
- Harden filename validation and normalization:
- Normalize all archive entry paths to a canonical form before use, resolving dot segments (
.and..) and symbolic links where applicable. - Reject any filename that, once normalized, escapes the intended root extraction directory or contains traversal segments.
- Enforce a strict whitelist for allowed path patterns (e.g., no path separators at the start, no absolute paths, no leading
../, and no embedded traversal sequences).
- Constrain extraction to a controlled root:
- Build the extraction target path by joining a fixed, trusted root directory with the validated archive entry name.
- Verify after joining that the resulting path still resides under the trusted root (e.g., prefix or common-path checks) before opening the file.
- Re-order operations to eliminate the TOCTOU window:
- Perform integrity and authenticity checks (e.g., signature and manifest validation) on the archive contents before writing any file to disk.
- Where intermediate processing is unavoidable, restrict it to an in-memory buffer or a tightly controlled staging area that is fully removed on any failure, including files created during validation.
- Limit privileges and blast radius:
- Run the widget installation process with the minimum filesystem permissions necessary, avoiding write access to sensitive system locations.
- Apply filesystem sandboxing or containerization to isolate the installer, so that even if path traversal occurs, the reachable paths are low-privilege and non-critical.
These patterns reduce reliance on individual checks and ensure that untrusted content cannot persist or affect the broader system before passing strong validation.
How teams detect issues like this
Detection typically combines code-level analysis with process and filesystem monitoring:
- Static code analysis and review:
- Search for custom archive extraction logic that uses raw filenames from ZIP entries without robust normalization and traversal checks.
- Flag uses of APIs like
open,openat, orfopenwhere the path originates from archive metadata or other untrusted sources. - Examine validation functions (such as
is_valid_filename) to ensure they explicitly handle..,./, backslashes, and mixed separators. - Review control flow around security checks (e.g., signature verification) to verify that validation occurs before extraction or other side-effecting operations.
- Automated policy enforcement:
- Introduce secure coding guidelines for archive handling and have CI pipelines enforce patterns that require canonical path checks.
- Use static analysis tools configured with rules for Zip Slip (CWE-22) and TOCTOU (CWE-367) around filesystem operations.
- Runtime and test-based detection:
- Develop regression tests that install synthetic widgets containing
../paths and confirm that no files are written outside the expected directory. - Instrument installers to log unusual extraction paths and validate that written paths remain within the designated work directory.
These strategies help identify both existing vulnerable patterns and future regressions as code evolves.

