Skip to content

Various fixes part 2 - #6724

Merged
swick merged 16 commits into
flatpak:mainfrom
swick:wip/various-fixes-novuln-part2
Aug 4, 2026
Merged

swick merged 16 commits into
flatpak:mainfrom
swick:wip/various-fixes-novuln-part2

Conversation

@swick

@swick swick commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

All of those issues fell out of an LLM. I analyzed each issue, discarded a bunch, and either worked on, or at least verified the fixes.

Comment thread common/flatpak-docker-reference.c
Comment thread common/flatpak-dir-utils.c Outdated

@alexlarsson alexlarsson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some minor comment, but lgtm

swick added 12 commits August 4, 2026 13:25
In case something takes over the process, not having any supplementary
groups limits the damage that can be done.
The Deploy authorization handler decides between app-install (requires
admin auth) and app-update (no auth needed) by checking whether the ref
is currently installed. The deploy handler then independently checks the
deployed state to decide whether to install or update.

Record the authorization decision on the invocation and verify in the
deploy handler that the operation matches what was authorized.
handle_remove_local_ref validates the remote name but passes the ref
string directly to flatpak_dir_remove_ref without validation. Since the
polkit action for this method is modify-repo (allow_active=yes), any
active session user can delete arbitrary ostree refs in the system repo
without authentication.

All legitimate callers of RemoveLocalRef pass standard flatpak refs
(app/runtime). Non-standard refs like appstream/, appstream2/, and
ostree-metadata are managed through their own dedicated D-Bus methods
(DeployAppstream, UpdateRemote, ConfigureRemote) and never go through
RemoveLocalRef.

Validate the ref with flatpak_decomposed_new_from_ref() to restrict
removal to valid flatpak refs.
flatpak_oci_registry_mirror_blob uses self->token (destination registry)
instead of source_registry->token when downloading from the source. All
other parameters on the same call correctly use source_registry.

In practice the destination is always a local on-disk registry with no
token set, so this results in missing authentication when pulling from
authenticated source registries rather than a credential leak.
The appdata XML parser uses g_assert() to validate parser state in
several places. Since the XML comes from the app's deploy directory and
is controlled by the package author, malformed XML triggers abort().

Replace all g_assert() calls with graceful handling: early returns when
there is no current component, NULL checks for content_rating, and
state resets for accumulated text and lang.
The metadata, appstream, icon_64, and icon_128 fields are conditionally
initialized in flatpak_bundle_ref_new() depending on which keys exist in
the bundle metadata. The finalize function used g_bytes_unref() which is
not NULL-safe on older GLib versions.
The close function would bail out on the first child stream close
failure, skipping the remaining children. Close all children and
propagate the first error.
flatpak_permission_adds_permissions() had two bugs in its sorted-array
merge walk for comparing conditional permissions:

The function returned FALSE when a new conditional was not present in
the old set, which is the opposite of correct — a new conditional means
the permission can be granted under conditions it previously could not.

The loop also relied on reading a NULL sentinel past the end of the
GPtrArray, which is not NULL-terminated, causing an out-of-bounds read.

Replace with proper bounds-checked iteration that correctly detects new
conditionals as permission additions.
flatpak_docker_reference_parse() asserts that the regex always matches,
but inputs containing newlines cause the match to fail since the regex
is not compiled with G_REGEX_DOTALL. Return an error instead.
Instead of just blindly accepting any characters to make up the docker
registry domain, reject invalid domains (including ones which contain
e.g. '@', '#', and '?').
@swick
swick force-pushed the wip/various-fixes-novuln-part2 branch from ff1c283 to 9bf7681 Compare August 4, 2026 11:25
swick added 4 commits August 4, 2026 13:29
The subtraction-based comparison overflows when priority values are far
apart, which is undefined behavior in C.
Every other access to index->manifests in the codebase checks for NULL
before dereferencing, but flatpak_image_collection_new did not. Add the
same guard to avoid a NULL pointer dereference if the OCI index has no
manifests array.
The commit metadata and ref validation checks in validate_commit_metadata()
and flatpak_dir_deploy() used G_IO_ERROR which gets downgraded to a generic
G_DBUS_ERROR_FAILED when crossing the system helper D-Bus boundary.
Use FLATPAK_ERROR_PERMISSION_DENIED so the error is preserved across D-Bus.
A component without an <id> element causes a NULL dereference when
parsing appdata.
@swick
swick force-pushed the wip/various-fixes-novuln-part2 branch from 9bf7681 to dc75767 Compare August 4, 2026 11:30
@swick

swick commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you!

@swick
swick enabled auto-merge August 4, 2026 11:30
@swick
swick added this pull request to the merge queue Aug 4, 2026
Merged via the queue into flatpak:main with commit a2900bb Aug 4, 2026
11 checks passed
@swick
swick deleted the wip/various-fixes-novuln-part2 branch August 4, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants