Skip to content

SQL injection in the contact duplicate-email check #402

Closed

Description

@caseysoftware

CContact::canCreate() (modules/contacts/contacts.class.php) puts the e-mail address straight into SQL:

$recordCount = $this->loadAll(null, "contact_email = '".$this->contact_email."'");

isValid() checks the address with FILTER_VALIDATE_EMAIL, but that filter accepts characters such as ' in the part before the @. An address with an apostrophe (a legitimate one like o'[email protected], or a crafted one) breaks the query or changes it. Anyone who can create contacts can reach this, and contacts are created for new users too.

The v5.0 release fixed the same pattern in the public sign-up form; this one is in the model.

Fix: quote the value ($q->quote($this->contact_email)) or build the condition with w2p_Database_Query and addWhere() on a quoted value. A search for other loadAll(..., "... = '" . $value . "'") calls would be worthwhile.

Activity

  1. added a commit that references this issue on Oct 21, 2026
    89e8ee1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions