Skip to content

fix: remediate 8 security vulnerabilities (CSRF, amount bypass, @Transactional, input validation, headers, dependency CVE)#177

Open
devin-ai-integration[bot] wants to merge 3 commits intoDevOpsfrom
devin/1777433096-security-remediation
Open

fix: remediate 8 security vulnerabilities (CSRF, amount bypass, @Transactional, input validation, headers, dependency CVE)#177
devin-ai-integration[bot] wants to merge 3 commits intoDevOpsfrom
devin/1777433096-security-remediation

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 29, 2026

Summary

Implements targeted fixes for 8 confirmed/likely security vulnerabilities identified during security audit. All fixes are minimal, scoped, and verified to not break existing tests.

Findings Remediated

# ID Severity Fix Description Build Tests Regressions Status
1 C1 Critical Re-enable CSRF protection, update all forms to use th:action, convert logout to POST pass pass no remediated
2 C2 Critical Add amount > 0 validation in deposit/withdraw/transfer pass pass no remediated
3 C3 High Add @Transactional to deposit/withdraw/transfer methods pass pass no remediated
4 C4 Medium Add username (≥3 chars) and password (≥8 chars) validation on registration pass pass no remediated
5 C6 Medium Replace "Username already exists" with generic error message pass pass no remediated
6 C8 Medium Update mysql-connector-java 8.0.33 → mysql-connector-j 9.1.0 pass pass no remediated
7 C10 Low Add Content-Type-Options and HSTS security headers pass pass no remediated
8 Build Config Fix maven-compiler-plugin source/target from 1.8 → 17 pass pass no remediated

Files Changed

  • SecurityConfig.java — Removed csrf.disable(), added HSTS + content-type headers, changed logout to POST-only
  • AccountService.java — Added @Transactional, positive amount validation, input length validation, generic registration error
  • pom.xml — Updated mysql-connector groupId/version, fixed compiler source/target to 17, added H2 test dependency
  • login.html — Changed form action to th:action=\"@{/login}\"
  • register.html — Changed form action to th:action=\"@{/register}\", display dynamic error message
  • dashboard.html — Changed all form actions to th:action, converted logout link to POST form
  • transactions.html — Converted logout link to POST form
  • src/test/resources/application.properties — Added H2 in-memory DB config for tests

Remediated: 8 | Not remediated: 0
Build status: pass | Test suite: pass (1 test, 0 failures)

Review & Testing Checklist for Human

  • CSRF protection: Verify all POST forms include CSRF tokens by inspecting rendered HTML (check for _csrf hidden input). Test that submitting a form without a valid CSRF token is rejected (403).
  • Negative amount bypass: Try depositing/withdrawing/transferring negative or zero amounts — should get "Amount must be positive" error.
  • Registration validation: Try registering with username < 3 chars or password < 8 chars — should get validation errors. Try registering a duplicate username — should get generic message (not "Username already exists").
  • Logout: Verify logout button works as a POST form (not a GET link). Confirm navigating to /logout via GET no longer logs out.
  • MySQL connector: If deploying to production with MySQL, verify the new com.mysql:mysql-connector-j:9.1.0 connects properly.

Notes

  • Added com.h2database:h2 as a test-scoped dependency and src/test/resources/application.properties to enable the existing @SpringBootTest context test to run without a MySQL instance.
  • The logout AntPathRequestMatcher now requires POST method, matching the new form-based logout in the templates.
  • Branch: devin/1777433096-security-remediation

Link to Devin session: https://app.devin.ai/sessions/c59e301e861b46508257802ae123bf52
Requested by: @angelalincog


Open in Devin Review

C1: Re-enable CSRF protection (remove csrf.disable()), update all HTML
forms to use th:action for automatic CSRF token inclusion, convert
logout to POST form

C2: Add positive amount validation in deposit(), withdraw(), and
transferAmount() to prevent negative amount bypass

C3: Add @transactional to deposit(), withdraw(), and transferAmount()
to ensure atomicity

C4: Add username/password length validation in registerAccount()

C6: Replace 'Username already exists' with generic error message to
prevent username enumeration

C8: Update mysql-connector-java 8.0.33 to mysql-connector-j 9.1.0
(new groupId com.mysql)

C10: Add security headers (Content-Type-Options, HSTS) in SecurityConfig

Build: Fix maven-compiler-plugin source/target from 1.8 to 17

Also adds H2 test dependency and test application.properties for
in-memory database during tests.

Co-Authored-By: Angela  Lin <angela.lin@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@staging-devin-ai-integration
Copy link
Copy Markdown

Devin Review

Status Commit
⚪ Not started

Open in Devin Review (Staging)

💡 Connect your GitHub account to enable automatic code reviews.

devin-ai-integration[bot]

This comment was marked as resolved.

…t error handling

- Use username.trim().length() for consistent validation with trim-based emptiness check
- Add try-catch in BankController.deposit() to handle amount validation errors gracefully
  instead of returning a raw 500 error page

Co-Authored-By: Angela  Lin <angela.lin@cognition.ai>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: Angela  Lin <angela.lin@cognition.ai>
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