Skip to content

system/nxpkg: Validate catalog and database contents before use. - #3718

Open
aviralgarg05 wants to merge 1 commit into
apache:masterfrom
aviralgarg05:gsoc/nxpkg-metadata
Open

system/nxpkg: Validate catalog and database contents before use.#3718
aviralgarg05 wants to merge 1 commit into
apache:masterfrom
aviralgarg05:gsoc/nxpkg-metadata

Conversation

@aviralgarg05

Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Depends-On: /pull/3642

Summary

A manifest read from a catalog, and an entry read from the installed
database, were used as they arrived. A name or a version containing a path
separator therefore reached the filesystem, and a database could name a
current version that it did not list among the installed ones.

This checks those fields are usable as a single path component, that the
current and previous versions appear in the recorded version list, and
applies a size limit to each field.

Version comparison also had two problems: it could overflow on a long
numeric prefix, and it treated versions sharing that prefix as equal, so 1a
and 1b compared the same. It now compares the numeric part without
overflowing and falls back to the remainder.

The manifest gains an optional icon, and the manifest actually recorded for
an installed version can now be read back, which matters after a rollback
has left the installed version behind the catalog.

This is the second of four parts of #3642, which was one commit covering
several unrelated changes.

Impact

  • New feature: NO, this is validation and correctness on existing paths.
  • User adaptation: NO.
  • Build: NO.
  • Hardware: NO.
  • Documentation: NO.
  • Security: YES. A catalog or database that has been tampered with can no
    longer smuggle a path traversal through a name or version field.
  • Compatibility: A manifest whose fields were already valid parses as
    before. One that was not is now rejected instead of being acted on.

Testing

Build host: macOS 26.5, arm64, xtensa-esp-elf-gcc 14.2.0
(esp-14.2.0_20251107).

Target: Xtensa / ESP32-S3, Waveshare ESP32-S3-Touch-LCD-7.

This commit does not build on master alone because it uses declarations
added by #3642; the Depends-On line above lets CI apply that first.

PR verification Self-Check

  • This PR introduces one focused change.
  • I have updated all required description fields above.
  • I have reviewed and signed every commit.
  • This PR adheres to the current contribution and coding guidelines.
  • My PR is still work in progress.
  • My PR is ready for review and can be safely merged.

A manifest and an installed-database entry were trusted as read. A name or
a version carrying a path separator therefore reached the filesystem, and a
database could name a current version it did not list as installed.

Check that those fields are usable as single path components, that the
current and previous versions appear among the installed ones, and apply a
size limit to each field. Compare versions by their numeric prefix without
overflowing, falling back to the remainder so that 1a and 1b are not read
as the same version. Carry an optional icon and record the manifest of the
version actually installed, which a rollback can leave behind the catalog.

Assisted-by: OpenAI Codex:gpt-5.6-sol
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/31526606011

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants