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

Potential Second Order SQLi in ConceptValidatorChangeSet.isNameUniqueInLocale

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Design
    • Priority: Non-Essential
    • Resolution: Unresolved
    • Affects Version/s: OpenMRS 1.9.3
    • Fix Version/s: None
    • Component/s: None
    • Complexity:
      Undetermined

      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.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            burke Burke Mamlin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Time Tracking

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