Repository navigation
Conversation
Establish a byte-for-byte baseline for the unified Swift port, including query help, its example, and all Swift test sources. Adaptations follow separately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Inline the data flow configuration and query-specific models unchanged from ECBEncryptionQuery.qll and ECBEncryptionExtensions.qll. Mark their provenance before adapting to unified APIs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Model CryptoSwift ECB construction and reuse existing AES and Blowfish sinks with value-preserving global flow. All nine original CryptoSwift cases are detected; record four pre-existing CommonCrypto misses as inline expectations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Describe ECB's plaintext-pattern leakage rather than replay attacks. Recommend authenticated encryption and clarify that the CBC example needs ciphertext authentication and does not by itself prevent replay. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sue with original Swift. It seems fine with unified Swift.
…to newer .json format.
Generate a separate random IV for each AES cipher construction rather than sharing a CBC block mode between the two examples. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
QHelp previews: unified/ql/src/queries/security/CWE-327/ECBEncryption.qhelpEncryption using ECBECB should not be used as a mode for encryption. With a fixed key, identical plaintext blocks always produce identical ciphertext blocks. This can expose sensitive information by revealing patterns in the plaintext. RecommendationUse an authenticated encryption mode such as GCM where available. If CBC is used, generate a fresh, unpredictable initialization vector for each encryption and use a separate message authentication mechanism to protect ciphertext integrity. ExampleThe following example shows six cases of instantiating a cipher with different block modes. In the 'BAD' cases, the encryption mode is ECB, which reveals patterns in the plaintext. In the 'GOOD' cases, the encryption mode is CBC with a randomly generated initialization vector, avoiding this issue. Authentication of the ciphertext is not shown. func encrypt(key : Key, padding : Padding) {
// ...
// BAD: ECB is used for block mode
_ = try AES(key: key, blockMode: ECB(), padding: padding)
_ = try AES(key: key, blockMode: ECB())
_ = try Blowfish(key: key, blockMode: ECB(), padding: padding)
// GOOD: ECB is not used for block mode
_ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)), padding: padding)
_ = try AES(key: key, blockMode: CBC(iv: AES.randomIV(AES.blockSize)))
_ = try Blowfish(key: key, blockMode: CBC(iv: Blowfish.randomIV(Blowfish.blockSize), padding: padding)
// ...
}References
|
Port the ECB encryption query from Swift to Unified Swift, as
unified/swift/ecb-encryption. Used Copilot with GPT-6.1 Sol, high effort, some manual and agent authored fixes afterwards.A few thoughts:
commoncryptotest cases)..qhelp. I often revert this kind of thing, but in this case it appears the original.qhelpwas outdated and in places not very accurate. I iterated on the changes a bit instead. Both the description and suggestions are better now in my opinion. Obviously a docs review will be required.