Skip to content

SQl-Injection lesson 4 not deleting created row #961

Closed

Description

@SturmCamper

In the 4th lesson the goal is to alter a table by adding new Row ('phone').
While it works for the first time, the added row never is deleted.


image


The main problem accrues when u want to retry the lesson. U are able to create custom rows and still get an approval.
Also if WebGoat is used by multiple people it may lead to confusions, since they aren't able to complete the task properly.


image


protected AttackResult injectableQuery(String query) {
try (Connection connection = dataSource.getConnection()) {
try (Statement statement = connection.createStatement(TYPE_SCROLL_INSENSITIVE, CONCUR_READ_ONLY)) {
statement.executeUpdate(query);
connection.commit();
ResultSet results = statement.executeQuery("SELECT phone from employees;");
StringBuffer output = new StringBuffer();
// user completes lesson if column phone exists
if (results.first()) {
output.append("<span class='feedback-positive'>" + query + "</span>");
return success(this).output(output.toString()).build();
} else {
return failed(this).output(output.toString()).build();
}
} catch (SQLException sqle) {
return failed(this).output(sqle.getMessage()).build();
}
} catch (Exception e) {
return failed(this).output(this.getClass().getName() + " : " + e.getMessage()).build();
}

Activity

  1. nbaars commented on Mar 29, 2021

    @nbaars
    Collaborator

    We can solve this one for now by making the column name random, but we need is to have each user have their schema in the database. This way we solve it once for all. Otherwise, it will be "hacky" in a way we need to let the user create a random column name, etc.

    Until now we have already split the database user administration from the lesson but the lessons need a different schema for each user.

    We would probably have to create a specific DataSource bean which will before it creates a statements alters the current schema. This way it is transparent while building a lesson.

  2. self-assigned this
    on Mar 29, 2021
  3. added this to the 8.1.1 milestone on Mar 29, 2021
  4. added a commit that references this issue on Apr 10, 2021
  5. added
    waiting for release
    and removed on Apr 10, 2021
  6. added a commit that references this issue on Apr 16, 2021
  7. added and removed
    waiting for release
    on Jul 27, 2021
  8. modified the milestones: 8.1.1, 8.2.0 on Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions