{"record":{"id":"b1ba9c47d1defeb4","repo":"phacility/phabricator","slug":"file-data-integrity-check-failed-dark-forces-have","errorCode":null,"errorMessage":"File data integrity check failed. Dark forces have corrupted or tampered with this file. The file data can not be read.","messagePattern":"File data integrity check failed\\. Dark forces have corrupted or tampered with this file\\. The file data can not be read\\.","errorType":"exception","errorClass":"PhabricatorFileIntegrityException","httpStatus":null,"severity":"critical","filePath":"src/applications/files/engine/PhabricatorFileStorageEngine.php","lineNumber":342,"sourceCode":"      return null;\n    }\n\n    return $engine->getChunkSize();\n  }\n\n  public function getRawFileDataIterator(\n    PhabricatorFile $file,\n    $begin,\n    $end,\n    PhabricatorFileStorageFormat $format) {\n\n    $formatted_data = $this->readFile($file->getStorageHandle());\n\n    $known_integrity = $file->getIntegrityHash();\n    if ($known_integrity !== null) {\n      $new_integrity = $this->newIntegrityHash($formatted_data, $format);\n      if (!phutil_hashes_are_identical($known_integrity, $new_integrity)) {\n        throw new PhabricatorFileIntegrityException(\n          pht(\n            'File data integrity check failed. Dark forces have corrupted '.\n            'or tampered with this file. The file data can not be read.'));\n      }\n    }\n\n    $formatted_data = array($formatted_data);\n\n    $data = '';\n    $format_iterator = $format->newReadIterator($formatted_data);\n    foreach ($format_iterator as $raw_chunk) {\n      $data .= $raw_chunk;\n    }\n\n    if ($begin !== null && $end !== null) {\n      $data = substr($data, $begin, ($end - $begin));\n    } else if ($begin !== null) {\n      $data = substr($data, $begin);","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/engine/PhabricatorFileStorageEngine.php#L324-L360","documentation":"Before serving file data, PhabricatorFileStorageEngine::getRawFileDataIterator() recomputes the integrity hash over the stored (formatted) bytes and compares it to the hash recorded at write time with phutil_hashes_are_identical(). A mismatch raises PhabricatorFileIntegrityException: the bytes in storage differ from what was written — corruption, truncation, or the data being read through a different format/key material than it was written with. Note the AES-256 format folds the per-file IV into the integrity hash, so format/property drift also trips this check.","triggerScenarios":"Stored blob bytes were altered or truncated (disk/S3/database); files written unencrypted are read through the AES-256 format or vice versa; per-file storage properties (iv.base64/payload.base64) were mangled; the integrity hash column was hand-edited.","commonSituations":"Bit rot or a partially failed disk; operators editing stored blobs in place; enabling at-rest encryption or cycling keys without running the storage format migration; restoring storage backends from mismatched snapshots.","solutions":["If storage-format settings, keyring keys, or encryption were changed, re-encode affected files with Phabricator's storage format migration tooling instead of forcing reads","Compare the stored object against a known-good copy or backup to confirm real corruption, and restore the good copy","Never modify stored file data in place; if a file is unrecoverable, remove its record explicitly rather than serving altered bytes","Audit per-file storage properties (format, iv/payload) for the affected files to rule out metadata corruption"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch PhabricatorFileIntegrityException specifically; do not retry (deterministic), never serve the bytes anyway, alert operators, and return an explicit 'file corrupted' response.","preventionTips":["Run the storage format migration when enabling encryption or cycling keyring keys","Never edit stored file data in place","Back up the storage backend together with the database and monitor for this exception — each hit is detected corruption or config drift"],"tags":["storage","integrity","encryption","corruption","hash-mismatch"],"backgroundTag":"data-integrity-check-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}