Skip to content

Fix/857 directobject try with resources - #919

Open
shishir-cyber wants to merge 3 commits into
OWASP:devfrom
shishir-cyber:fix/857-directobject-try-with-resources
Open

shishir-cyber wants to merge 3 commits into
OWASP:devfrom
shishir-cyber:fix/857-directobject-try-with-resources

Conversation

@shishir-cyber

Copy link
Copy Markdown
Contributor

Part of #857

Converts the 5 DB-touching files in the DirectObject* family (DirectObject1, DirectObject2, DirectObjectBankLogin, DirectObjectBankRegistration, DirectObjectBankTransfer) to try-with-resources, following the same pattern used in #834/#846.
DirectObjectBankCurrentBalance and DirectObjectBankLogout are excluded since neither touches the database.

Connections were previously only closed at the end of the try block, so any exception skipped cleanup. getAccountBalance() had it worse, every exceptional path leaked, including a condition it throws itself.

No behavior change, same queries, same output, same intentionally vulnerable IDOR in DirectObject1/2.

Verified: google-java-format clean, mvn test passes.

= and others added 3 commits September 2, 2026 16:54
…dmin

Replace the inaccurate "JavaScript validation bypassed" ERROR log with
an accurate WARN message describing a server-side validation failure.

- Log the length of the offending username/password/address fields
  instead of asserting a JS bypass, so operators can tell which
  constraint (username 3-32 chars, password 8-512 chars, address
  <=128 chars) was violated.
- Never log the actual field values (especially the password).
- Downgrade log level from ERROR to WARN, since this is a routine
  input-validation rejection, not a tamper signal.
- Apply the same fix to CreateNewAdmin.java, which had the identical
  issue.
- User-facing response message is unchanged.

Fixes OWASP#860
Replaces manual Database.closeConnection() calls with try-with-resources
for Connection/PreparedStatement/ResultSet, closing a connection leak on
the exception path. Verified with spotless:apply and mvn test (169 passed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant