aws / aws/aws-encryption-sdk-javascript

Return friendly error if input is Base64 encoded

未关闭
#630 1 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
TypeScript
星标
260
派生
68
平均合并
22 小时 19 分钟
30 天内合并 PR
2

描述

### Problem:

We have some code that intends to return a friendly error if the first byte is base64 encoded:
- https://github.com/aws/aws-encryption-sdk-javascript/blob/43813f463ef6c53bd4de1963e7843b56733d1bec/modules/serialize/src/deserialize_header_v1.ts#L88-L93
- https://github.com/aws/aws-encryption-sdk-javascript/blob/43813f463ef6c53bd4de1963e7843b56733d1bec/modules/serialize/src/deserialize_header_v2.ts#L92-L96

However we can't ever get inside those statements because we first do a check at: https://github.com/aws/aws-encryption-sdk-javascript/blob/43813f463ef6c53bd4de1963e7843b56733d1bec/modules/serialize/src/deserialize_factory.ts#L74

### Solution:

Move the logic checking the expected first byte in Base64 before the branch that determines which version we're deserializing.

### Out of scope:

n/a

[//]: # (NOTE: If you believe this might be a security issue, please email aws-security@amazon.com instead of creating a GitHub issue. For more details, see the AWS Vulnerability Reporting Guide: https://aws.amazon.com/security/vulnerability-reporting/ )

贡献指南

打开贡献指南

调研方向

从 modules/serialize/src/deserialize_factory.ts 开始,然后比较 deserialize_header_v1.ts 和 deserialize_header_v2.ts 中对第一个字节的处理。跟踪当前的版本选择分支,并验证 Base64 编码的输入会在选择反序列化版本之前产生易于理解的错误;确认相关的序列化测试通过。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
backend
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。