Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-3939

Potential Second Order SQLi in ConceptValidatorChangeSet.isNameUniqueInLocale

    XMLWordPrintable

    Details

    • Complexity:
      Undetermined
    • Development:

      Description

      credit: Timothy D. Morgan

      The escapeSqlWildcards method likely only escapes wildcard characters, not ' and the like.

      private boolean isNameUniqueInLocale(JdbcConnection connection, ConceptName conceptName, int conceptId) {
      
        int duplicates = getInt(connection,
          "SELECT count(*) FROM concept_name cn, concept c WHERE cn.concept_id = c.concept_id  AND (cn.concept_name_type = '"
            + ConceptNameType.FULLY_SPECIFIED
            + "' OR cn.locale_preferred = '1') AND cn.voided = '0' AND cn.name = '"
            + HibernateUtil.escapeSqlWildcards(conceptName.getName(), connection.getUnderlyingConnection())
            + "' AND cn.locale = '"
            + HibernateUtil.escapeSqlWildcards(conceptName.getLocale().toString(), connection
              .getUnderlyingConnection()) + "' AND c.retired = '0' AND c.concept_id != " + conceptId);
      
          return duplicates == 0;
      }
      

      Make sure that this code ConceptValidatorChangeSet.isNameUniqueInLocale does not allow SQL injection attacks.

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              grace Grace Potma
              Reporter:
              burke Burke Mamlin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4 hours
                  4h
                  Remaining:
                  Remaining Estimate - 4 hours
                  4h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified