TypeError: crypto.createCipher is not a function — fix on Node.js 22 Lambda

Lambda broken after Node.js 22 upgrade? Fix TypeError by migrating to createCipheriv with secure key derivation. Full guide.

domingo, 26 de julio de 2026 • 4 min read • Q2BSTUDIO Team

Solución para createCipheriv en Node.js 22 Lambda

In the AWS Lambda ecosystem, upgrading to Node.js 22 has triggered an unexpected error in many functions that used the crypto.createCipher method. The message TypeError: crypto.createCipher is not a function appears when trying to perform cryptographic operations, indicating that this function has been completely removed. This change is not arbitrary but responds to a long-announced security decision: the original method derived the encryption key using EVP_BytesToKey with MD5, without salt and with a single iteration, making it vulnerable to brute-force and dictionary attacks. Node.js marked it as deprecated since version 10, emitted runtime warnings from v11, and finally removed it in v22. For companies running applications on AWS Lambda, especially those handling sensitive data, this change forces an urgent migration to using crypto.createCipheriv with robust key derivation.

The migration is not trivial because it involves modifying both encryption and decryption, and also managing old data that was already protected with the deprecated method. For those who have already updated their runtime to Node.js 22, the first reaction is often to look for a magic flag like --openssl-legacy-provider, but that option only restores the old hash provider for compilation, not the removed functions. The only durable solution is to rewrite the code using crypto.createCipheriv and crypto.scryptSync (or pbkdf2Sync) to derive the key from a password, adding a random 16-byte salt and a random initialization vector (IV). This process guarantees that each encryption is unique, even with the same password, and that the derivation is resistant to attacks using specialized hardware like GPU or ASIC.

The most complex scenario arises when there is already data encrypted with the old API. The createCipher function internally used an 8-byte salt (prefixed with 'Salted__') or none if not specified. To decrypt that legacy data, it is necessary to reproduce exactly the same derivation process with EVP_BytesToKey, which is only possible with an older version of Node.js (≤21). The professional recommendation is to run a temporary script in an older Node.js environment, decrypt to plaintext, and re-encrypt with the new pattern. This can be done inside a Lambda with a previous runtime or on a local machine, always under strict cybersecurity measures to avoid exposing data during the transition.

Besides the technical migration, it is wise to review all project dependencies. A search with grep -r 'createCipher' node_modules/ will reveal which third-party libraries are using the deprecated method. Many encryption and authentication libraries released updated versions years ago, but if any have not, they must be patched or replaced. In enterprise environments where business continuity depends on data integrity, this type of audit is critical. Q2BSTUDIO, as a software development and technology company, offers custom software development services that include security reviews, runtime upgrades, and legacy system migration.

The AWS Lambda deprecation schedule also adds pressure. The Node.js 20.x runtime became obsolete on April 30, 2026, with no security patches since that date. Functions still using it must migrate to Node.js 22 before the block dates (create-block: February 1, 2027; update-block: March 3, 2027). If a company has not planned this migration, development teams will hit the createCipher error exactly when they try to upgrade, causing delays and potential vulnerabilities. Integrating cloud services like AWS or Azure with a solid cloud AWS/Azure strategy enables automating these transitions and maintaining data security.

From a broader perspective, this change reflects an industry trend toward modern cryptographic algorithms resistant to brute-force attacks. Using scrypt as a key derivation function, for example, is memory-hard, which hinders massive parallelism. Artificial intelligence solutions and intelligent agents also benefit from these practices, since secure handling of sensitive data is a cross-cutting requirement. At Q2BSTUDIO, we accompany organizations in AI integration and in adopting cybersecurity standards that protect both encrypted data and machine learning pipelines.

For teams working with Business Intelligence (BI) and Power BI, the security of source data is equally relevant. If a Lambda application extracts, transforms, and encrypts data before loading it into a data warehouse, a broken encryption can interrupt complete reporting flows. Therefore, Q2BSTUDIO offers consulting services in BI / Power BI that include reviewing security layers in data pipelines.

In summary, the disappearance of crypto.createCipher in Node.js 22 is not a mere compatibility error but an opportunity to improve application security. The migration requires a careful plan that includes code rewriting, re-encryption of legacy data, and dependency auditing. Companies that act in advance, with the support of technology partners like Q2BSTUDIO, can carry out this transition smoothly and also strengthen their overall security posture. Do not wait for the error to appear in production: review your runtimes, update your code, and secure your data with best practices.

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.