Skip to content

🔒 [security fix] Replace insecure XOR encryption with AES-GCM#7

Merged
sebamar88 merged 3 commits intomainfrom
fix-insecure-xor-encryption-6513175462402756418
Mar 18, 2026
Merged

🔒 [security fix] Replace insecure XOR encryption with AES-GCM#7
sebamar88 merged 3 commits intomainfrom
fix-insecure-xor-encryption-6513175462402756418

Conversation

@sebamar88
Copy link
Copy Markdown
Owner

🎯 What:

Fixed the security vulnerability where sensitive data was being encrypted using insecure XOR-based encryption.

⚠️ Risk:

XOR encryption is trivial to break, especially with repetitive keys or known plaintext, potentially exposing sensitive data to attackers.

🛡️ Solution:

  • Replaced the core encryption logic with AES-256-GCM via the Web Crypto API.
  • Added support for random initialization vectors (IV) to prevent identical inputs from producing identical ciphertexts.
  • Kept the original XOR methods but marked them as @deprecated with console warnings to ensure backward compatibility while guiding developers toward the secure alternative.
  • Optimized Base64 conversions for both Node.js and browser environments.

PR created automatically by Jules for task 6513175462402756418 started by @sebamar88

- Implemented secure asynchronous `encrypt` and `decrypt` methods using AES-256-GCM.
- Used SHA-256 for key derivation from secret strings.
- Included random 96-bit IV for non-deterministic encryption.
- Deprecated `xorEncrypt` and `xorDecrypt` methods with security warnings.
- Updated tests to cover both new AES-GCM and existing XOR methods.
- Maintained backward compatibility for existing sync XOR calls.

Co-authored-by: sebamar88 <4359231+sebamar88@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

google-labs-jules bot and others added 2 commits March 17, 2026 16:38
- Implemented secure asynchronous `encrypt` and `decrypt` methods using AES-256-GCM.
- Used SHA-256 for key derivation from secret strings.
- Included random 96-bit IV for non-deterministic encryption.
- Deprecated `xorEncrypt` and `xorDecrypt` methods with security warnings.
- Updated tests to cover both new AES-GCM and existing XOR methods.
- Fixed TypeScript type errors by passing `.buffer` to `importKey`.
- Restored `pnpm-lock.yaml` and `verify-fix.js` to avoid unrelated changes.

Co-authored-by: sebamar88 <4359231+sebamar88@users.noreply.github.com>
- Implemented secure asynchronous `encrypt` and `decrypt` methods using AES-256-GCM.
- Used SHA-256 for key derivation from secret strings.
- Included random 96-bit IV for non-deterministic encryption.
- Deprecated `xorEncrypt` and `xorDecrypt` methods with security warnings.
- Updated tests to cover both new AES-GCM and existing XOR methods.
- Fixed TypeScript type errors by applying `as any` to `importKey` and `encrypt`/`decrypt` parameters to accommodate environment-specific types.
- Restored `pnpm-lock.yaml` and `verify-fix.js` to avoid unrelated changes.

Co-authored-by: sebamar88 <4359231+sebamar88@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

@sebamar88 sebamar88 merged commit 2c8dfc5 into main Mar 18, 2026
7 of 17 checks passed
sebamar88 added a commit that referenced this pull request Mar 29, 2026
…hunks (#7)

- Extend FileUploadOptions with resumeFrom (0-based chunk index) and concurrency
  (max parallel chunks, windowed Promise.all batching)
- Extend UploadResponse with uploadedChunks and totalChunks for resume support
- Clamp edge cases: chunkSize<=0 falls back to 5 MB default, concurrency<1 -> 1,
  resumeFrom<0 -> 0, resumeFrom>=totalChunks -> immediate success (zero fetches)
- Progress baseline pre-initialised from skipped chunks so percentage is
  accurate across the entire file when resuming
- All changes are non-breaking (all new fields optional, default concurrency=1
  preserves original sequential behaviour)
- 21 tests passing (9 existing + 12 new covering US1/US2/US3 + edge cases)
- Add examples/resumable-upload.ts demonstrating all three user stories
- Add specs/007-resumable-uploads/ planning artifacts (plan, research, data-model,
  contracts, quickstart, tasks)
sebamar88 added a commit that referenced this pull request Mar 29, 2026
…hunks (#7) (#19)

- Extend FileUploadOptions with resumeFrom (0-based chunk index) and concurrency
  (max parallel chunks, windowed Promise.all batching)
- Extend UploadResponse with uploadedChunks and totalChunks for resume support
- Clamp edge cases: chunkSize<=0 falls back to 5 MB default, concurrency<1 -> 1,
  resumeFrom<0 -> 0, resumeFrom>=totalChunks -> immediate success (zero fetches)
- Progress baseline pre-initialised from skipped chunks so percentage is
  accurate across the entire file when resuming
- All changes are non-breaking (all new fields optional, default concurrency=1
  preserves original sequential behaviour)
- 21 tests passing (9 existing + 12 new covering US1/US2/US3 + edge cases)
- Add examples/resumable-upload.ts demonstrating all three user stories
- Add specs/007-resumable-uploads/ planning artifacts (plan, research, data-model,
  contracts, quickstart, tasks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant