/usr/share/apport/whoopsie-upload-all:binascii.Error:/usr/share/apport/whoopsie-upload-all@249:main:collect_info:process_report:load:_decompress_line:b64decode

Bug #1997912 reported by errors.ubuntu.com bug bridge
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
Fix Released
High
Unassigned
apport (Ubuntu)
Fix Released
High
Benjamin Drung
Kinetic
Won't Fix
High
Unassigned
Lunar
Triaged
High
Benjamin Drung

Bug Description

Impact
======

apport-unpack and whoopsie-upload-all can crash when fed with a malformed problem report. They should print a proper error message instead of crashing.

Test Plan
=========

1. Create malformed report:
```
printf "CoreDump: base64\n H4sICAAAAAAC/0NvcmVEdW1wAA==\n 7Z0LYFPV/cdP0rQ\n" > malformed.crash
```
2. Try to unpack it:
```
apport-unpack malformed.crash unpack
```

It should print an error message instead of a stack trace.

Where problems could occur
==========================

The patch touches the problem report handling and therefore can affect apport-unpack, apport-bug, whoopsie-upload-all. The change is covered with tests and apport has a test suite running during build and as autopkgtest.

Original report
===============

```
Traceback (most recent call last):
  File "/usr/share/apport/whoopsie-upload-all", line 249, in <module>
    main()
  File "/usr/share/apport/whoopsie-upload-all", line 231, in main
    stamps = collect_info()
  File "/usr/share/apport/whoopsie-upload-all", line 162, in collect_info
    res = process_report(r)
  File "/usr/share/apport/whoopsie-upload-all", line 76, in process_report
    r.load(f, binary="compressed")
  File "/usr/lib/python3/dist-packages/problem_report.py", line 139, in load
    bd, value = self._decompress_line(line, bd, value)
  File "/usr/lib/python3/dist-packages/problem_report.py", line 276, in _decompress_line
    block = base64.b64decode(line)
  File "/usr/lib/python3.10/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
```

The Ubuntu Error Tracker has been receiving reports about a problem regarding apport. This problem was most recently seen with package version 2.23.1-0ubuntu3, the problem page at https://errors.ubuntu.com/problem/dd58c8169d2ec8468ccccb8b37471dfb701ac31c contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports.
If you do not have access to the Ubuntu Error Tracker and are a software developer, you can request it at http://forms.canonical.com/reports/.

Benjamin Drung (bdrung)
description: updated
Changed in apport:
milestone: none → 2.24.0
importance: Undecided → High
Changed in apport (Ubuntu):
importance: Undecided → High
Changed in apport (Ubuntu Kinetic):
importance: Undecided → High
Revision history for this message
Benjamin Drung (bdrung) wrote :
Revision history for this message
Benjamin Drung (bdrung) wrote :
Changed in apport:
status: New → Fix Committed
Changed in apport (Ubuntu):
status: New → In Progress
assignee: nobody → Benjamin Drung (bdrung)
Benjamin Drung (bdrung)
Changed in apport:
status: Fix Committed → Fix Released
Benjamin Drung (bdrung)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.24.0-0ubuntu1

---------------
apport (2.24.0-0ubuntu1) lunar; urgency=medium

  * New upstream bug-fix release.
    - Catch malformed problem reports (LP: #1996040)
    - Catch ValueError: not enough values to unpack (LP: #1995100)
    - Catch FileNotFoundError for missing desktop files (LP: #1997753)
    - Catch binascii.Error: Incorrect padding (LP: #1997912)
    - Catch AttributeError: NoneType object has no attribute origins
      (LP: #1997973)
  * Drop cherry-picked upstream patches
  * oem-getlogs: Use colon instead of a dot for chown command
  * Remove redundant section from apport-noui
  * Clarify that apport-noui is empty
  * Run black, isort, pydocstyle, pylint during package build

 -- Benjamin Drung <email address hidden> Thu, 08 Dec 2022 01:37:20 +0100

Changed in apport (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello errors.ubuntu.com, or anyone else affected,

Accepted apport into kinetic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apport/2.23.1-0ubuntu3.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-kinetic to verification-done-kinetic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-kinetic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in apport (Ubuntu Kinetic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-kinetic
Revision history for this message
Benjamin Drung (bdrung) wrote :

Failed to verify:

```
(kinetic)root@deep-thought:~# dpkg -s apport | grep Version
Version: 2.23.1-0ubuntu3.3
(kinetic)root@deep-thought:~# printf "CoreDump: base64\n H4sICAAAAAAC/0NvcmVEdW1wAA==\n 7Z0LYFPV/cdP0rQ\n" > malformed.crash
(kinetic)root@deep-thought:~# apport-unpack malformed.crash unpack
Traceback (most recent call last):
  File "/usr/bin/apport-unpack", line 84, in <module>
    pr.extract_keys(f, bin_keys, args.target_directory)
  File "/usr/lib/python3/dist-packages/problem_report.py", line 244, in extract_keys
    bd, line_value = self._decompress_line(
  File "/usr/lib/python3/dist-packages/problem_report.py", line 300, in _decompress_line
    raise MalformedProblemReport(
problem_report.MalformedProblemReport: Malformed problem report: Incorrect padding.
```

The exception is MalformedProblemReport, but apport-unpack does not print an error message for it.

tags: added: verification-failed-kinetic
removed: verification-needed-kinetic
Benjamin Drung (bdrung)
Changed in apport (Ubuntu):
status: Fix Released → Triaged
Changed in apport:
status: Fix Released → Triaged
Revision history for this message
Benjamin Drung (bdrung) wrote :

Reopening the upstream bug and mark lunar as affected as well, because the upstream fix was only partial. Here is the remaining bit: https://github.com/canonical/apport/pull/161

Changed in apport:
milestone: 2.24.0 → 2.27.0
Revision history for this message
Benjamin Drung (bdrung) wrote :

https://github.com/canonical/apport/pull/161 was merged and will be part of the next apport release.

Changed in apport:
status: Triaged → Fix Committed
Revision history for this message
Steve Langasek (vorlon) wrote : Proposed package removed from archive

The version of apport in the proposed pocket of Kinetic that was purported to fix this bug report has been removed because one or more bugs that were to be fixed by the upload have failed verification and been in this state for more than 10 days.

Changed in apport (Ubuntu Kinetic):
status: Fix Committed → Confirmed
Benjamin Drung (bdrung)
Changed in apport:
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.27.0-0ubuntu2

---------------
apport (2.27.0-0ubuntu2) mantic; urgency=medium

  * Run only pylint --errors-only and mypy from tests/run-linters (LP: #2028881)
  * Depend on dictionaries-common for having a dpkg diversion test package
    (LP: #2028879)

 -- Benjamin Drung <email address hidden> Fri, 28 Jul 2023 18:59:34 +0200

Changed in apport (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

Ubuntu 22.10 (Kinetic Kudu) has reached end of life, so this bug will not be fixed for that specific release.

Changed in apport (Ubuntu Kinetic):
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.