#1141267 python3-apt: apt_pkg.config.value_list() segfaults on non-ASCII bytes in apt config

Package:
python3-apt
Source:
python3-apt
Description:
Python 3 interface to libapt-pkg
Submitter:
Date:
2026-07-02 12:09:02 UTC
Severity:
normal
Tags:
#1141267#5
Date:
2026-07-02 11:50:09 UTC
From:
To:
Dear Maintainer,

apt_pkg.config.value_list() segfaults when an apt configuration list
contains a non-ASCII byte.

Minimal reproducer:

import apt_pkg
import tempfile

apt_pkg.init_config()

with tempfile.NamedTemporaryFile("wb", delete=False) as f:
    f.write(b'Test {\x80};\n')
    p = f.name

apt_pkg.read_config_file(apt_pkg.config, p)
apt_pkg.config.value_list(“Test")

Actual result:

  Segmentation fault inside apt_pkg.cpython-313-aarch64-linux-gnu.so

Expected result:

  The malformed configuration should be rejected with an exception or
  parse error instead of crashing the Python interpreter.

I originally hit this through unattended-upgrades after an invalid byte
was accidentally inserted in /etc/apt/apt.conf.d/50unattended-upgrades.
I reduced it to the python3-apt reproducer above.

This appears related to #995118, but affects
apt_pkg.config.value_list() rather than apt_pkg.TagSection.keys().

I also reproduced the issue on x86, so it does not appear to be
arm64-specific.