CVE-2026-59016 AI-generated analysis
platform/packages/modules/Profiling, ProfilingService (anomaly profile result handling)
Adds enforceValidResultFileName() to ProfilingService.sendAnomalyProfile(). A caller-supplied resultFileName that is null or empty, contains path separators or "..", or resolves outside sTempTracePath (/data/misc/perfetto-traces/profiling/) is now rejected with IllegalArgumentException before a TracingSession is created with it.
Root cause
ProfilingService.sendAnomalyProfile() (service/java/com/android/os/profiling/ProfilingService.java) took the resultFileName binder argument. After only enforceSystemCaller() and enforceAnomalyTriggerType(), it stored the name unchanged via session.setFileName(resultFileName) on a new TracingSession. Per the commit message, the file name is later concatenated with sTempTracePath (/data/misc/perfetto-traces/profiling/) in file operations: a read via receiveFileDescriptor and a delete via deleteProfilingFiles. A name containing traversal sequences could therefore make the service read or delete arbitrary files with system_server privileges.
How the fix works
- ProfilingService.java:sendAnomalyProfile(): a new call to enforceValidResultFileName(resultFileName) is inserted after enforceAnomalyTriggerType(triggerType) and before the work is posted to the handler. Validation therefore runs synchronously on the calling thread, before the handler post.
- ProfilingService.java:enforceValidResultFileName() (new): throws IllegalArgumentException if the name is null or empty (TextUtils.isEmpty), contains '/' or '\\', contains the substring "..", or differs from new File(resultFileName).getName().
- ProfilingService.java:enforceValidResultFileName(): also resolves resultFileName against the normalized absolute sTempTracePath and normalizes the result. It throws if the resolved path does not start with the base directory or if its parent is not exactly the base directory. Any other exception from the Path operations is wrapped in IllegalArgumentException.
Completeness
- The fix validates only the sendAnomalyProfile() entry point. The diff does not change the consuming paths named in the commit message (receiveFileDescriptor, deleteProfilingFiles). Per the commit message, those paths concatenate the session file name with sTempTracePath, so they rely on every producer of a session file name being validated.
- The diff does not show whether any other IProfilingService method or internal path sets a TracingSession file name from caller input, so coverage of other producers is unknown.
- The substring check on ".." is stricter than needed: it also rejects single-component names such as "a..b". This restricts behavior but is not a gap.
- Validation is layered (string checks plus normalized Path resolution with a parent-equality check), so a name must resolve to a direct child of the base directory.
Behavior changes
- sendAnomalyProfile() now throws IllegalArgumentException for file names that are null, empty, contain a separator or "..", or are not a direct child of the base directory. Before the fix, such names were accepted.
- Validation happens before the handler post, so rejected requests never create a TracingSession.
- No change when the anomalyDetectorCoreC flag is off: the method still returns early after logging.
Per major
- Android 14: Not affected per the bulletin. The Profiling project is not present in android-security-14.0.0_r31.
- Android 15: Not affected per the bulletin. At android-security-15.0.0_r19, 0/6 lines of the patched region are present.
- Android 16: Not affected per the bulletin. At android-security-16.0.0_r10, 0/6 lines of the patched region are present.
- Android 17: Same fix. Commit a7abbb79d9a3 (Change-Id I30adfd935a60ac2b878e60cda2b12b1f6423d25b, which lists two Cherrypick-From commits) is in android-security-17.0.0_r3, with 6/6 lines of the patched region present.
Unknowns
- Whether other IProfilingService methods or internal code set a TracingSession file name from caller-controlled input (the diff only touches sendAnomalyProfile).
- The exact code of receiveFileDescriptor and deleteProfilingFiles that concatenates sTempTracePath with the file name (described in the commit message, not shown in the diff).
- Whether sendAnomalyProfile() or the consuming code exists in some form in the 15 and 16 trees.
- The body of enforceSystemCaller().
- What each of the two Cherrypick-From internal commits contained individually. The only test listed is manual.