Skip to content

Fix JDBC Resource Leaks in SQL Injection Challenges - #932

Open
LucaBonamino wants to merge 2 commits into
OWASP:devfrom
LucaBonamino:dev#931
Open

LucaBonamino wants to merge 2 commits into
OWASP:devfrom
LucaBonamino:dev#931

Conversation

@LucaBonamino

Copy link
Copy Markdown

This PR addresses the JDBC resource leaks reported in #931.

Several SQL Injection challenges do not properly release database connections, statements, and result sets. As a result, repeated requests can exhaust the HikariCP connection pools, causing subsequent queries to fail until Tomcat is restarted.

Changes

  • Use Java's try-with-resources to ensure JDBC resources are properly closed.
  • Ensure database connections are returned to the HikariCP pools, even when
    SQL queries fail or exceptions occur.
  • Preserve the existing SQL queries and the intentionally vulnerable behavior
    of the challenges.

The changes address resource management without altering the educational
purpose of the SQL Injection exercises.

Testing

After applying the fix and rebuilding the application, repeated valid and malformed SQL queries no longer exhausted the affected connection pools during local testing.

Related issue

Fixes #931

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[BUG] SQL Injection Challenges 1,2,3,4 and 5 Stop Working After Several Queries

2 participants