CVE-2026-58814 AI-generated analysis
platform/frameworks/base, telephony/common com.google.android.mms.pdu.PduParser (MMS PDU parsing); plus platform/development samples/ApiDemos com.example.android.mmslib.pdu.PduParser copy
Adds a `length < 0` rejection to the value-length bounds check in PduParser.parseContentType, so a negative Value-length decoded from a crafted MMS PDU no longer passes the check and no longer triggers a huge array allocation (OutOfMemoryError in com.android.phone). The fix is applied in both platform/frameworks/base (telephony/common) and the platform/development ApiDemos mmslib copy.
Root cause
In PduParser.parseContentType, when the first byte is below TEXT_MIN, the Content-general-form path reads a Value-length via parseValueLength(pduDataStream) and records startPos = pduDataStream.available(). In frameworks/base the only validation was `if (length > startPos)`. In the development ApiDemos copy there was no validation at all. parseValueLength can return a negative int for a crafted uintvar (the test uses the encoding for Integer.MIN_VALUE), and a negative length passes `length > startPos`. Per the commit message, the later length arithmetic then underflows and the parser allocates a massive byte array (new byte[2GiB]), raising OutOfMemoryError in com.android.phone.
How the fix works
- platform/frameworks/base ca82d1b14a6a, telephony/common/com/google/android/mms/pdu/PduParser.java:parseContentType: the existing check `if (length > startPos)` becomes `if (length < 0 || length > startPos)`. On failure it logs "parseContentType: Invalid length ..." and returns PduContentTypes.contentTypes[0].getBytes() ("*/*") instead of continuing to parse with the bogus length.
- platform/frameworks/base ca82d1b14a6a, tests/TelephonyCommonTests/src/com/google/android/mms/pdu/PduParserTest.java: moves @SmallTest from each method to the class. The testPduParserUnderflowOOM test (CONTENT_TYPE 0x84, LENGTH_QUOTE 0x1F, uintvar for Integer.MIN_VALUE, well-known type 0x83) already exists in the pre-fix file and exercises the path.
- platform/development 486b14ff1ad2, samples/ApiDemos/src/com/example/android/mmslib/pdu/PduParser.java:parseContentType: inserts the full block `if (length < 0 || length > startPos) { Log.e(...); return (PduContentTypes.contentTypes[0]).getBytes(); }` after startPos is computed. This copy had no check before.
- platform/development 486b14ff1ad2: adds samples/ApiDemos/tests/src/com/example/android/mmslib/pdu/PduParserTest.java (testPduParserUnderflowOOM, which fails on OutOfMemoryError) and switches the ApiDemos test instrumentation in samples/ApiDemos/tests/AndroidManifest.xml from android.test.InstrumentationTestRunner to androidx.test.runner.AndroidJUnitRunner.
Completeness
- The fix covers only the Value-length read in parseContentType (the cur < TEXT_MIN branch) in both PduParser copies. Negative and oversized lengths are now both rejected there.
- parseValueLength itself is not changed to reject or clamp negative results, so any other call sites of parseValueLength in PduParser.java still depend on their own local checks. The material does not show those call sites, so their state is unknown.
- The development ApiDemos copy previously had no length check at all. After the fix it matches the frameworks/base check exactly.
- Test-only changes (annotation move, runner switch) have no runtime effect on the parser.
Behavior changes
- A Content-Type header whose Value-length decodes to a negative int is now treated as invalid: an error is logged and the content type falls back to "*/*" (PduContentTypes.contentTypes[0]) instead of parsing continuing with the underflowed length.
- ApiDemos tests (platform/development) now run under androidx.test.runner.AndroidJUnitRunner instead of android.test.InstrumentationTestRunner.
Per major
- Android 14: same fix: platform/frameworks/base ca82d1b14a6a (adds `length < 0 ||` to the existing check) and platform/development 486b14ff1ad2 (adds the whole check block plus test and runner change) in android-security-14.0.0_r31; 8/8 patched lines present.
- Android 15: same fix: platform/frameworks/base 590206444279 in android-security-15.0.0_r19, the same one-line change to telephony/common PduParser.java (same pre/post blob ids as 14) plus the test annotation move; the resolver reports 7/8 patched lines present. The material does not show a development commit for 15.
- Android 16: same fix: platform/development 30da2e23c0be in android-security-16.0.0_r10, identical to the 14 development commit; 8/8 patched lines present. The material does not show a frameworks/base commit for 16.
- Android 17: same fix: platform/frameworks/base 2b289745379d in android-security-17.0.0_r3, the same one-line change at the same location (different file blob ids 3ad9cb93f9eb -> 080ee91866e3) plus the test annotation move; the resolver reports 7/8 patched lines present.
Unknowns
- The shown context does not include the downstream code in parseContentType that does the underflowing arithmetic and the 2GiB allocation. Only the commit message describes it.
- Whether the earlier commit that introduced the `length > startPos` check and the pre-existing testPduParserUnderflowOOM test in frameworks/base is part of this CVE's fix set.
- Why the resolver reports 7/8 patched lines for Android 15 and 17 but 8/8 for 14 and 16, and whether both repositories were patched on every major (the material shows only one commit each for 15, 16 and 17).
- Whether there is any ordering dependency between the platform/development and platform/frameworks/base commits.