Skip to content

feat(security): encrypt game and player names with env-based key - #2743

Closed
Adarshkumar0509 wants to merge 14 commits into
OWASP:masterfrom
Adarshkumar0509:fix/encrypt-game-player-names-clean
Closed

feat(security): encrypt game and player names with env-based key#2743
Adarshkumar0509 wants to merge 14 commits into
OWASP:masterfrom
Adarshkumar0509:fix/encrypt-game-player-names-clean

Conversation

@Adarshkumar0509

@Adarshkumar0509 Adarshkumar0509 commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

Implements field-level encryption for game.name and player.name as requested in #2232.

Uses Cloak and Cloak.Ecto for AES-256-GCM authenticated encryption. The vault
is configured via the COPI_ENCRYPTION_KEY environment variable in production.
A deterministic test key is configured in test.exs so CI runs without any
additional setup.

The database migration converts the name columns from varchar to binary.
Existing plaintext data is preserved during migration and remains readable
until re-encrypted on next write.

Tested locally with PostgreSQL — 13 tests passing.

Resolved or fixed issue: #2232

###Ai disclosure
Used AI to assist with implementation. The logic, integration with the existing schema and application layer, and all verification were done manually including running migrations and tests locally. No AI-generated noise or unnecessary comments are present in the code. All code are manually written.

…OWASP#2232

Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
@Adarshkumar0509
Adarshkumar0509 marked this pull request as draft March 27, 2026 20:48
Adarshkumar0509 and others added 10 commits March 28, 2026 09:46
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
Signed-off-by: Adarsh Kumar <adarshkumarthakur0509@gmail.com>
@Adarshkumar0509
Adarshkumar0509 marked this pull request as ready for review March 28, 2026 10:25
@Adarshkumar0509

Copy link
Copy Markdown
Collaborator Author

@sydseter please check this out ,Happy to make any changes you suggest.

@sydseter

Copy link
Copy Markdown
Collaborator

@Adarshkumar0509 That won't work, we will need to migrate the data and encrypt it in order to be able to load existing player names. Otherwise you get a mismatch between the strings that is saved in the database and the new binary type.

@sydseter sydseter closed this Mar 31, 2026
@Adarshkumar0509

Copy link
Copy Markdown
Collaborator Author

Ok sir I will be working on this

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.

2 participants