bug(node): SigV4 presign date applies the epoch offset twice — media uploads can never validate

Open Beginner friendly
#29 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
aws, rust
Domain
backend, databases

Research direction

Start with sigv4_timestamps in src/psi_service.rs and the existing presigning test, which currently checks URL fields but not the date. Check how civil_date_from_days applies the epoch offset, then add regression coverage that compares X-Amz-Date with the credential scope and verifies the real UTC date. Done when the regression catches the incorrect year and the requested Rust checks pass.

Written by the indexing model from the issue text.

Description

area::node effort::s impact::medium priority::medium source::auto status::review type::bug

Problem

POST /v1/media/presign returns presigned S3 URLs whose X-Amz-Date is ~1970 years in the future, so MinIO/S3 rejects every upload and the media path is unusable even when object storage is healthy.

Evidence (live deployment, 2026-12-04)

With MinIO running, the node answered:

{"presigned_url":"http://minio:9000/sonaraim-media-ephemeral/deadbeef?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...%2F39961005%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=39961005T184857Z&..."}

The time part (184857Z) matches the current UTC time, but the date part is 3996-10-05 instead of 2026-12-04.

Root cause

src/psi_service.rs:

let (year, month, day) = civil_date_from_days((epoch_secs / 86_400) as i64 + 719_468);

civil_date_from_days already adds 719_468 internally (let z = days + 719_468;), so the offset is applied twice — exactly 1970 years.

The existing test only asserted that the URL contains X-Amz-Algorithm, X-Amz-Signature and AKIDEXAMPLE, never that the date is correct, so the defect passed.

Expected vs actual

  • Expected: X-Amz-Date is the current UTC timestamp and the signature validates against MinIO/S3.
  • Actual: the date is ~1970 years ahead and no upload can succeed.

Acceptance criteria

  1. sigv4_timestamps produces the real civil date (single epoch offset).
  2. A regression test fails if the date is not the current UTC date (or is not within a sane year range) and pins that X-Amz-Date and the credential scope agree.
  3. cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test are green.
Dominant language
Rust
Stars
0
Forks
0
Avg merge
4m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alfonsodg/sonaraim-node

All issues in alfonsodg/sonaraim-node

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.