{"record":{"id":"3eab934fc5741568","repo":"MuntashirAkon/AppManager","slug":"paxheader-value-size-restlen-exceeds-size-of-header-record","errorCode":null,"errorMessage":"Paxheader value size ${restLen} exceeds size of header record","messagePattern":"Paxheader value size (.+?) exceeds size of header record","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java","lineNumber":709,"sourceCode":"                if (ch == '\\n') { // blank line in header\n                    break;\n                } else if (ch == ' '){ // End of length string\n                    // Get keyword\n                    final ByteArrayOutputStream coll = new ByteArrayOutputStream();\n                    while((ch = inputStream.read()) != -1) {\n                        read++;\n                        totalRead++;\n                        if (totalRead < 0 || (headerSize >= 0 && totalRead >= headerSize)) {\n                             break;\n                         }\n                        if (ch == '='){ // end of keyword\n                            final String keyword = coll.toString(CharsetNames.UTF_8);\n                            // Get rest of entry\n                            final int restLen = len - read;\n                            if (restLen <= 1) { // only NL\n                                headers.remove(keyword);\n                            } else if (headerSize >= 0 && restLen > headerSize - totalRead) {\n                                throw new IOException(\"Paxheader value size \" + restLen\n                                    + \" exceeds size of header record\");\n\n                            } else {\n                                final byte[] rest = new byte[restLen];\n                                final int got = IOUtils.readFully(inputStream, rest);\n                                if (got != restLen) {\n                                    throw new IOException(\"Failed to read \"\n                                            + \"Paxheader. Expected \"\n                                            + restLen\n                                            + \" bytes, read \"\n                                            + got);\n                                }\n                                totalRead += restLen;\n                                // Drop trailing NL\n                                if (rest[restLen - 1] != '\\n') {\n                                    throw new IOException(\"Failed to read Paxheader.\"\n                                       + \"Value should end with a newline\");\n                                }","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java#L691-L727","documentation":"Thrown by TarUtils.parsePaxHeaders when a PAX extended header record declares a keyword/value whose remaining length (restLen) is larger than the bytes actually available in the header record (headerSize - totalRead). The library detects that the PAX record would overrun its containing 512-byte record block, i.e. a corrupt or maliciously crafted archive.","triggerScenarios":"Reading a TAR entry whose PAX header contains a record where the declared length field points past the end of the current header record; typically corrupt data or a deliberately malformed file (CVE-hardening check).","commonSituations":"Opening archives produced by broken writers, files truncated/modified in transit, or fuzzed/test corpus archives with inconsistent PAX length fields.","solutions":["Verify archive integrity (checksum, re-download/re-transfer the tar file)","Re-pack the archive with a standard tool: tar --format=pax or GNU tar, avoiding hand-edited PAX headers","If producing archives yourself, use TarArchiveOutputStream rather than hand-writing PAX records","Catch IOException and reject the archive as malformed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!archiveFile.isFile() || archiveFile.length() == 0) throw new IOException(\"archive missing or empty\");","typeGuard":null,"tryCatchPattern":"try (TarArchiveInputStream in = new TarArchiveInputStream(fis)) {\n    // read entries\n} catch (IOException e) {\n    if (e.getMessage().contains(\"exceeds size of header record\")) {\n        throw new CorruptArchiveException(\"Malformed PAX header record\", e);\n    }\n    throw e;\n}","preventionTips":["Verify archive checksums/integrity before extraction","Only consume archives produced by standard tar implementations","Don't hand-edit PAX header records"],"tags":["tar","pax-header","corrupt-archive","io"],"backgroundTag":"unexpected-response-shape","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}