E07910: sanitized parameters must be String type

Category: E07xxx Full resolution · Reported in phase: EXPLICIT_TYPE_SYMBOL_DEFINITION · Classification: SANITIZED_PARAMETER_TYPE_INVALID · All error codes

What went wrong

The 'sanitized' modifier can ONLY be applied to String type parameters. The receiving function or method cleans a 'sanitized' parameter on entry, checking the String for injection patterns. This only makes sense for String types - other types don't have injection vulnerability semantics.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 661 (Why can sanitized only be used on incoming String paramet...)
  • ek9 -q 665 (How do sanitized parameters work with web service content...)

Rationale

Sanitization prevents injection attacks (SQL injection, XSS, command injection). These attacks exploit string interpolation into commands or markup. Non-string types like Integer, Boolean, or objects don't have this attack vector.

How to fix it

  1. Remove 'sanitized' modifier from non-String parameters
  2. Use sanitized only for String parameters that receive external input
  3. For non-String types, use normal type validation

Common causes

  • Misunderstanding sanitized as general "validation" (it's specifically for injection)
  • Copy-paste from String parameter to non-String parameter
  • Trying to apply security modifier to all external inputs

See also

  • E07910: sanitized on non-String type (this error)
  • E07920: sanitized in wrong location (not on incoming parameter)

https://ek9.io/sanitized.html https://ek9.io/forAI.json#$.sanitizedTypes

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E07910: sanitized parameters must be String type

#!ek9
defines module error.e07910.bad

  defines function

    //ERROR: Integer cannot be sanitized - only String
    processInteger()
      -> value as sanitized Integer
      <- result as Integer?
      result: value

    //ERROR: Float cannot be sanitized - only String
    processFloat()
      -> value as sanitized Float
      <- result as Float?
      result: value

    //ERROR: Date cannot be sanitized - only String
    processDate()
      -> value as sanitized Date
      <- result as Date?
      result: value

    //ERROR: Time cannot be sanitized - only String
    processTime()
      -> value as sanitized Time
      <- result as Time?
      result: value

    //ERROR: Duration cannot be sanitized - only String
    processDuration()
      -> value as sanitized Duration
      <- result as Duration?
      result: value

    //ERROR: Boolean cannot be sanitized - only String
    processBoolean()
      -> value as sanitized Boolean
      <- result as Boolean?
      result: value

    //VALID: String CAN be sanitized - this should NOT produce an error
    processString()
      -> value as sanitized String
      <- result as String?
      result: value

Fixed: Use 'sanitized' only on a String parameter

#!ek9
defines module error.e07910.good

  defines function

    //A String parameter can be sanitized
    executeQuery()
      -> sql as sanitized String
      <- rtn as String: sql

    //An Integer needs no sanitizing: text that is not a number never becomes one
    processCount()
      -> count as Integer
      <- rtn as Integer: count

Questions and answers

These Q&A entries show E07910 and its fix:

Found a problem?

If EK9 reported E07910 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.