aws / aws/aws-encryption-sdk-javascript

Return friendly error if input is Base64 encoded

Open
#630 1 comment 2 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
260
Forks
68
Avg merge
22h 19m
Merged PRs (30d)
2

Description

### 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/ )

Contributor guide

Open the contributing guide

Research direction

Start in modules/serialize/src/deserialize_factory.ts, then compare the first-byte handling in deserialize_header_v1.ts and deserialize_header_v2.ts. Trace the current version-selection branch and verify that Base64-encoded input reaches a friendly error before deserialization version selection; confirm the relevant serialization tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.