Commit eca6c90
Validate secret fields before JDBC URL construction (#334)
## Description
### Why is this change being made?
1. To prevent URL injection attacks (CWE-610) where malicious characters
in secret fields could be used to manipulate JDBC URLs and bypass
security controls or redirect connections to unintended databases.
### What is changing?
1. Added `validateSecretFields()` method in `AWSSecretsManagerDriver`
that validates the `host`, `port`, and `dbname` fields from secrets
before URL construction.
### Related Links
- **Issue #, if available**: N/A
---
## Testing
### How was this tested?
1. Added new test methods for this change.
### When testing locally, provide testing artifact(s):
1. `mvn clean test` `Tests run: 155, Failures: 0, Errors: 0, Skipped: 0`
---
## Reviewee Checklist
**Update the checklist after submitting the PR**
- [x] I have reviewed, tested and understand all changes
*If not, why:*
- [x] I have filled out the Description and Testing sections above
*If not, why:*
- [x] Build and Unit tests are passing
*If not, why:*
- [x] Unit test coverage check is passing
*If not, why:*
- [x] I have ensured no sensitive information is leaking (i.e., no
logging of sensitive fields, or otherwise)
*If not, why:*
- [x] I have added explanatory comments for complex logic, new
classes/methods and new tests
*If not, why:*
- [ ] I have updated README/documentation (if needed)
*If not, why:*
- [ ] I have clearly called out breaking changes (if any)
*If not, why:*
---
## Reviewer Checklist
**All reviewers please ensure the following are true before reviewing:**
- Reviewee checklist has been accurately filled out
- Code changes align with stated purpose in description
- Test coverage adequately validates the changes
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
---------
Co-authored-by: Vedant Jaiswal <vedjasy@amazon.com>1 parent 62bfcd9 commit eca6c90
2 files changed
Lines changed: 130 additions & 0 deletions
File tree
- src
- main/java/com/amazonaws/secretsmanager/sql
- test/java/com/amazonaws/secretsmanager/sql
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
111 | 116 | | |
112 | 117 | | |
113 | 118 | | |
| |||
377 | 382 | | |
378 | 383 | | |
379 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
380 | 405 | | |
381 | 406 | | |
382 | 407 | | |
| |||
400 | 425 | | |
401 | 426 | | |
402 | 427 | | |
| 428 | + | |
403 | 429 | | |
404 | 430 | | |
405 | 431 | | |
| |||
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
359 | 463 | | |
0 commit comments