crypto Cipher/Decipher validation issues
未关闭
还没有人认领这个 Issue。
confirmed-bug
crypto
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
This also affects Decipher methods.
Here's an example:
const { createCipheriv, randomBytes } = require('crypto');
const cipher = createCipheriv('aes-256-cbc', randomBytes(32), randomBytes(16));
cipher.update('test', 'utf-8', 'bad');
Gives an internal assertion:
Error [ERR_INTERNAL_ASSERTION]: Cannot change encoding
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
final has the same issue:
const { createCipheriv, randomBytes } = require('crypto');
const cipher = createCipheriv('aes-256-cbc', randomBytes(32), randomBytes(16));
cipher.update('test', 'utf-8', 'utf-8');
cipher.final('bad');
Other issue:
const { createCipheriv, randomBytes } = require('crypto');
const cipher = createCipheriv('aes-256-cbc', randomBytes(32), randomBytes(16));
let result = cipher.update('test', 'bad', 'hex');
result += cipher.final('hex');
console.log(result);
Gives no error at all for the wrong input encoding.
@nodejs/crypto
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行 issue 中的 Cipher 和 Decipher 示例,并检查它们所经过的 crypto Cipher/Decipher 方法路径。比较 update 和 final 对无效输入编码与输出编码的处理。完成的标准是:无效编码会收到适当的验证错误,而不是触发内部断言或被静默接受。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- api, security
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100