NationalSecurityAgency/ghidra · error · LSHException

Bad characters in one or more proposed ${type}

Error message

Bad characters in one or more proposed ${type}

What it means

In checkStrings each name is validated by CategoryRecord.enforceTypeCharacters, which rejects null/empty strings and any character that is not alphanumeric, space, '.', '_', ':', '/', '(', ')'. Failure throws LSHException naming the offending 'type'.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java:2900

		}
		if (query.info.execats != null) {
			checkStrings(query.info.execats, "categories", -1);
			config.info.execats = query.info.execats;
		}
		generate(config);
		response.info = config.info;
	}

	private static void checkStrings(List<String> list, String type, int limit)
			throws LSHException {
		if (limit > 0 && list.size() > limit) {
			throw new LSHException("Too many " + type + " specified (limit=" +
				FunctionTagBSimFilterType.MAX_TAG_COUNT + "): " + list.size());
		}
		Set<String> names = new HashSet<>();
		for (String name : list) {
			if (!CategoryRecord.enforceTypeCharacters(name)) {
				throw new LSHException("Bad characters in one or more proposed " + type);
			}
			if (!names.add(name)) {
				throw new LSHException("Duplicate " + type + " entry specified: " + name);
			}
		}
	}

	/**
	 * Entry point for the InstallCategoryRequest command:
	 *   Install a new executable category to be managed by the database
	 * @param query is command parameters
	 * @throws LSHException if the command is misconfigured
	 * @throws ElasticException for communication problems with the server
	 */
	private void fdbInstallCategory(InstallCategoryRequest query)
			throws LSHException, ElasticException {
		ResponseInfo response = query.installresponse;
		if (!CategoryRecord.enforceTypeCharacters(query.type_name)) {

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Sanitize each name to the allowed character set (alphanumeric, space, . _ : / ( )) before submitting.
  2. Strip leading/trailing whitespace and drop empty strings.
  3. Replace common offenders like '-' or '@' with '_'.

Example fix

// before
List<String> names = readLines(configFile); // contains 'foo-bar'
query.setCategories(names);
// after
List<String> names = readLines(configFile).stream()
    .map(s -> s.trim().replaceAll("[^A-Za-z0-9 ._:\/()]", "_"))
    .filter(s -> !s.isEmpty())
    .toList();
query.setCategories(names);
Defensive patterns

Strategy: validation

Validate before calling

// Validate every name up front.
for (String n : list) {
    if (!CategoryRecord.enforceTypeCharacters(n))
        throw new IllegalArgumentException("Invalid name: " + n);
}

Type guard

boolean allValid = list.stream().allMatch(CategoryRecord::enforceTypeCharacters);

Prevention

When it happens

Trigger: Passing a category/tag name (in a list validated by checkStrings) that is empty or contains disallowed punctuation such as '-', ';', '"', '*', '&', '@', '[', ']', or newlines.

Common situations: Auto-generated names derived from file paths/symbols containing punctuation; shell-injected strings with quotes; trailing whitespace or newline from file reads.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/07ce7d346b2fe707. Report an issue: GitHub.