{"record":{"id":"5567f9b2ab52146f","repo":"shwenzhang/AndResGuard","slug":"config-size-28","errorCode":null,"errorMessage":"Config size < 28","messagePattern":"Config size < 28","errorType":"exception","errorClass":"brut.androlib.AndrolibException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java","lineNumber":852,"sourceCode":"    return filterInfo;\n  }\n\n  private void writeValue() throws IOException, AndrolibException {\n    /* size */\n    mOut.writeCheckShort(mIn.readShort(), (short) 8);\n    /* zero */\n    mOut.writeCheckByte(mIn.readByte(), (byte) 0);\n    byte type = mIn.readByte();\n    mOut.writeByte(type);\n    int data = mIn.readInt();\n    mOut.writeInt(data);\n  }\n\n  private void readConfigFlags() throws IOException, AndrolibException {\n    int size = mIn.readInt();\n    int read = 28;\n    if (size < 28) {\n      throw new AndrolibException(\"Config size < 28\");\n    }\n\n    boolean isInvalid = false;\n\n    short mcc = mIn.readShort();\n    short mnc = mIn.readShort();\n\n    char[] language = new char[] { (char) mIn.readByte(), (char) mIn.readByte() };\n    char[] country = new char[] { (char) mIn.readByte(), (char) mIn.readByte() };\n\n    byte orientation = mIn.readByte();\n    byte touchscreen = mIn.readByte();\n\n    int density = mIn.readUnsignedShort();\n\n    byte keyboard = mIn.readByte();\n    byte navigation = mIn.readByte();\n    byte inputFlags = mIn.readByte();","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java#L834-L870","documentation":"ARSCDecoder.readConfigFlags reads a resource table TYPE config structure and validates that its declared size is at least 28 bytes, the minimum defined by the Android resources.arsc format (ResTable_config header). A size smaller than 28 means the arsc chunk is malformed, truncated, or produced by a non-standard tool, so decoding cannot continue safely.","triggerScenarios":"Called during ARSC decode when iterating type configs: mIn.readInt() yields a config size < 28, i.e. the aapt-generated resources.arsc contains a ResTable_type entry with an undersized config header, or the stream is misaligned from earlier bad parsing.","commonSituations":"Processing an APK whose resources.arsc was built or rewritten by non-aapt tools (obfuscators, repackers), corrupted/truncated arsc files, or APKs from unusual build pipelines; also happens when a previous chunk was misread so the decoder reads garbage as the size field.","solutions":["Rebuild the APK's resources.arsc with the official aapt/aapt2 from the Android SDK and re-run AndResGuard","Verify the input APK is a valid, unmodified APK (aapt dump badging) before obfuscation","Upgrade AndResGuard to the latest version, which tolerates more arsc variants","If the arsc is intentionally non-standard, exclude it from processing or use --dont混淆 arsc options"],"exampleFix":"// before: decoding an APK compiled with a non-standard tool\nAndResGuard.process(apkFile);\n// after: rebuild resources with standard aapt2 first\n// ./gradlew assembleRelease  (aapt2-produced arsc)\nAndResGuard.process(apkFile);","handlingStrategy":"try-catch","validationCode":"// java\nFile arsc = extractArsc(apk);\nlong len = arsc.length();\nif (len < 8 || !isPlausibleArsc(arsc)) throw new IllegalArgumentException(\"resources.arsc looks malformed\");","typeGuard":"boolean isPlausibleArsc(File f) throws IOException {\n  try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(f)))) {\n    int type = in.readUnsignedShort();\n    int size = in.readInt();\n    return type == 0x0002 && size > 28; // RES_TABLE_TYPE with sane header\n  }\n}","tryCatchPattern":"try {\n  arscDecoder.decode(arscStream);\n} catch (AndrolibException e) {\n  if (e.getMessage().contains(\"Config size < 28\")) {\n    // fail fast: rebuild apk with aapt2; do not retry on the same input\n    throw new BuildException(\"Malformed resources.arsc — rebuild with official aapt/aapt2\", e);\n  }\n  throw e;\n}","preventionTips":["Only feed AndResGuard APKs built with official aapt/aapt2","Never double-process already obfuscated APKs","Run aapt dump resources as a pre-build sanity check","Keep AndResGuard up to date"],"tags":["android","arsc","resource-parsing","corrupt-input"],"backgroundTag":"invalid-config-value","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}