Skip to content

compose: add bounds checks when parsing malformed translation files#750

Open
orbisai0security wants to merge 2 commits into
ximion:mainfrom
orbisai0security:fix-oob-read-mo-qm-parsers
Open

compose: add bounds checks when parsing malformed translation files#750
orbisai0security wants to merge 2 commits into
ximion:mainfrom
orbisai0security:fix-oob-read-mo-qm-parsers

Conversation

@orbisai0security

@orbisai0security orbisai0security commented May 22, 2026

Copy link
Copy Markdown

Summary

Add defensive bounds checks when parsing gettext .mo and Qt .qm translation files in asc-utils-l10n.c.

Motivation

Malformed or truncated translation files can currently cause out-of-bounds reads while parsing translation metadata during AppStream compose processing. This is better framed as a robustness/crash-prevention issue rather than a high-severity security vulnerability.

Changes

  • Validate that gettext data is large enough to contain AscLocaleGettextHeader before copying it.
  • Validate that enough bytes remain before reading a Qt .qm section length.
  • Return a parse error for malformed/truncated input instead of reading past the buffer.

Notes

This is intended as defensive hardening for malformed input and to avoid crashes during compose processing.

Description: The gettext .mo file parser at compose/asc-utils-l10n.c performs memcpy operations without validating that the source data buffer is large enough. At line 131, it copies sizeof(AscLocaleGettextHeader) bytes without checking the data buffer length. At line 224, it reads 4 bytes at an offset without validating that offset+4 is within bounds. A truncated or malformed .mo file triggers out-of-bounds reads from heap memory.

Changes

  • compose/asc-utils-l10n.c

Verification

  • Build passes
  • Scanner re-scan confirms fix
  • LLM code review passed

Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
@github-actions github-actions Bot added the compose Affects appstream-compose label May 22, 2026
@ximion

ximion commented May 26, 2026

Copy link
Copy Markdown
Owner

I had also already found this using scrutineer. It's not really a security issue, but it could become a very annoying crash, so we definitely should have this fixed.

@orbisai0security

Copy link
Copy Markdown
Author

Thanks, that makes sense. I’m happy to reframe this as a robustness/crash fix rather than a high-severity security issue.

The core issue I was trying to address is that malformed or truncated translation files can cause out-of-bounds reads during AppStream compose parsing. Even if this is not realistically exploitable in the project’s threat model, rejecting malformed input before the memcpy / uint32 read should avoid crashes on bad .mo/.qm files.

I’ll update the PR title and description to remove the HIGH severity/security wording and describe it as defensive bounds checking for malformed translation files.

@orbisai0security orbisai0security changed the title fix: add bounds check before memcpy in asc-utils-l10n.c compose: add bounds checks when parsing malformed translation files May 27, 2026
@ximion

ximion commented May 27, 2026

Copy link
Copy Markdown
Owner

Please try to fix the CI failure as well:


../compose/asc-utils-l10n.c: In function 'asc_l10n_parse_file_gettext':
../compose/asc-utils-l10n.c:128:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  128 |         gsize data_len = 0;
      |         ^~~~~
../compose/asc-utils-l10n.c: In function 'asc_l10n_parse_file_qt':
../compose/asc-utils-l10n.c:312:17: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  312 |                 guint32 section_len = _read_uint32 (data, &m);
      |                 ^~~~~~~
cc1: all warnings being treated as errors

@orbisai0security

Copy link
Copy Markdown
Author

Please try to fix the CI failure as well:


../compose/asc-utils-l10n.c: In function 'asc_l10n_parse_file_gettext':
../compose/asc-utils-l10n.c:128:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  128 |         gsize data_len = 0;
      |         ^~~~~
../compose/asc-utils-l10n.c: In function 'asc_l10n_parse_file_qt':
../compose/asc-utils-l10n.c:312:17: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  312 |                 guint32 section_len = _read_uint32 (data, &m);
      |                 ^~~~~~~
cc1: all warnings being treated as errors

this is addressed.

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

Labels

compose Affects appstream-compose

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants