As context_key is an user entry and as it is used to build the JSON
string of alert, we could end up with an invalid event if the string
contains improper characters.
}
strlcpy(array_key, val, array_key_size);
} else if (strcmp(key, "context_key") == 0) {
+ for (size_t i = 0; i < strlen(val); i++) {
+ if (!isalnum(val[i]) && val[i] != '_') {
+ SCLogError("context_key can only contain alphanumeric characters and "
+ "underscores");
+ return -1;
+ }
+ }
if (strlen(val) > enrichment_key_size) {
SCLogError("'key' value too long (limit is %zu)", enrichment_key_size);
return -1;