Description
The AES decrypt() API accepts a CipherOptions object containing a mode field, but the supplied mode is never used during decryption.
As a result, calling:
decrypt(input, key, { mode: "CBC" })
follows the same execution path as any other mode, leading to behavior that differs from what callers expect when requesting CBC.
This affects downstream functionality that relies on the mode option, including the Padding Oracle Simulator.
Evidence
Public API
decrypt() accepts a CipherOptions object:
export function decrypt(
input: string,
key: string,
options: CipherOptions = {}
)
CipherOptions defines:
Current Execution Flow
The decryption path receives the options object but never checks or forwards options.mode.
if (options.instrument) {
result = aesInstrumented(inputBytes, keyBytes, true)
} else {
result = aesFast(inputBytes, keyBytes, true)
}
Both execution paths ignore the supplied mode.
Reproduction
- Call:
decrypt(ciphertext, key, {
mode: "CBC",
encoding: "hex"
})
-
Trace execution through aes.ts.
-
Observe that options.mode is never read or propagated.
Expected Behavior
The supplied mode should either:
- be honored during decryption, or
- be explicitly rejected if unsupported.
Ignoring a supported API option silently produces behavior that differs from caller expectations.
Actual Behavior
The supplied mode value is ignored without warning, and all requests follow the same decryption path.
This leads to inconsistent behavior for features that rely on CBC semantics, including the Padding Oracle Simulator.
Files
lib/cipher/symmetric/aes.ts
lib/attacks/paddingOracle.ts
Description
The AES
decrypt()API accepts aCipherOptionsobject containing amodefield, but the supplied mode is never used during decryption.As a result, calling:
follows the same execution path as any other mode, leading to behavior that differs from what callers expect when requesting CBC.
This affects downstream functionality that relies on the
modeoption, including the Padding Oracle Simulator.Evidence
Public API
decrypt()accepts aCipherOptionsobject:CipherOptionsdefines:mode?: stringCurrent Execution Flow
The decryption path receives the options object but never checks or forwards
options.mode.Both execution paths ignore the supplied mode.
Reproduction
Trace execution through
aes.ts.Observe that
options.modeis never read or propagated.Expected Behavior
The supplied
modeshould either:Ignoring a supported API option silently produces behavior that differs from caller expectations.
Actual Behavior
The supplied
modevalue is ignored without warning, and all requests follow the same decryption path.This leads to inconsistent behavior for features that rely on CBC semantics, including the Padding Oracle Simulator.
Files
lib/cipher/symmetric/aes.tslib/attacks/paddingOracle.ts