{"record":{"id":"3ca92c17e26df9a5","repo":"moodle/moodle","slug":"one-or-more-reserved-keys-found-in-instruction-file-when","errorCode":null,"errorMessage":"One or more reserved keys found in Instruction file when they should not be present.","messagePattern":"One or more reserved keys found in Instruction file when they should not be present\\.","errorType":"exception","errorClass":"CryptoException","httpStatus":null,"severity":"error","filePath":"public/lib/aws-sdk/src/S3/Crypto/InstructionFileMetadataStrategy.php","lineNumber":159,"sourceCode":"                }\n            }\n        }\n\n        // check if we are reading a V3 object\n        // if it is a V3 object some data is stored in the object metadata and some\n        // as in the instruction file\n        //= ../specification/s3-encryption/data-format/content-metadata.md#content-metadata-mapkeys\n        //# In the V3 format, the mapkeys \"x-amz-c\", \"x-amz-d\", and \"x-amz-i\" \n        //# MUST be stored exclusively in the Object Metadata\n        if (!empty($envelope[MetadataEnvelope::ENCRYPTED_DATA_KEY_V3])) {\n            // before loading the rest of the v3 metadata, we must check that:\n            //  1. the following values are not already present in the envelope, if they are\n            //      the instruction file is not correct.\n            if (!empty($envelope[MetadataEnvelope::CONTENT_CIPHER_V3])\n                || !empty($envelope[MetadataEnvelope::KEY_COMMITMENT_V3])\n                || !empty($envelope[MetadataEnvelope::MESSAGE_ID_V3]) \n            ) {\n                throw new CryptoException(\"One or more reserved keys found in\"\n                    . \" Instruction file when they should not be present.\");\n            }\n            // this data is stored in the original object's metadata\n            // V3 added x-amz-c, x-amz-d, x-amz-i, x-amz-3, x-amz-w, x-amz-m, x-amz-t\n            // x-amz-c, x-amz-d, x-amz-i are strictly stored on the object metadata\n            // the rest are stored in the instruction file\n            $envelope[MetadataEnvelope::CONTENT_CIPHER_V3] = $args['Metadata'][MetadataEnvelope::CONTENT_CIPHER_V3];\n            $envelope[MetadataEnvelope::KEY_COMMITMENT_V3] = $args['Metadata'][MetadataEnvelope::KEY_COMMITMENT_V3];\n            $envelope[MetadataEnvelope::MESSAGE_ID_V3] = $args['Metadata'][MetadataEnvelope::MESSAGE_ID_V3];\n\n            if (!MetadataEnvelope::isV3Envelope($envelope)) {\n                throw new CryptoException(\"Expected a V3 envelope but was unable to\"\n                    . \" constuct one.\");\n            }\n            return $envelope;\n        }\n        // if we are not reading a v3 object then it must be a v2 object\n        if (!MetadataEnvelope::isV2Envelope($envelope)","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/moodle/moodle/blob/48ea8c33227277e916cdd4079dbecef448b37f2c/public/lib/aws-sdk/src/S3/Crypto/InstructionFileMetadataStrategy.php#L141-L177","documentation":"Format-violation check in InstructionFileMetadataStrategy::load for V3 objects. When the instruction file contains the V3 encrypted data key (x-amz-3), the strategy expects the reserved mapkeys x-amz-c (content cipher), x-amz-d (key commitment), and x-amz-i (message id) to be stored exclusively in the S3 object's metadata. If any of these reserved keys is already present in the envelope built from the instruction file, the file was written by a non-conforming writer, so a CryptoException is thrown before the V3 metadata is merged from object metadata.","triggerScenarios":"Thrown at public/lib/aws-sdk/src/S3/Crypto/InstructionFileMetadataStrategy.php:159 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-encrypt the object with a conforming V3 encryption client so reserved keys (x-amz-c, x-amz-d, x-amz-i) are written to object metadata, not the instruction file","Inspect the instruction file JSON and confirm it only holds the allowed V3 keys (x-amz-3, x-amz-w, x-amz-t, x-amz-m, x-amz-w)","Restore the object metadata headers that should hold the reserved V3 keys if they were stripped by a copy operation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"48ea8c33227277e916cdd4079dbecef448b37f2c","analyzedAt":"2026-09-14T20:34:48.527Z","contentChangedAt":"2026-09-14T20:34:48.527Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}