Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-api): reject C1 control characters in display fields (R4-M4)

Diego Zacarias8262b5fe333f
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 6006e9e13..e8203c5c1 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.445",
+ "version": "0.1.446",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.445",
+ "version": "0.1.446",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-api/package.json b/control-api/package.json
index 383884035..9cb0d76e8 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.445",
+ "version": "0.1.446",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/routes/admin/resourceFieldValidation.ts b/control-api/src/routes/admin/resourceFieldValidation.ts
index 379c58bd4..d108260b5 100644
--- a/control-api/src/routes/admin/resourceFieldValidation.ts
+++ b/control-api/src/routes/admin/resourceFieldValidation.ts
@@ -23,6 +23,9 @@ export const DISPLAY_FIELD_MAX_LENGTH = 120
// Characters rejected in display fields:
// - C0 range + DEL (\x00-\x1f, \x7f): newlines and tabs are control characters
// too — a display name is a single-line label.
+// - C1 range (\x80-\x9f): the second control block. U+0085 (NEL) is a line
+// terminator that breaks the "single-line label" invariant, and U+009B (CSI)
+// opens an ANSI escape sequence — both must be rejected like C0/DEL.
// - Unicode bidirectional formatting: embeddings/overrides (U+202A–U+202E:
// LRE/RLE/PDF/LRO/RLO) and isolates (U+2066–U+2069: LRI/RLI/FSI/PDI). These
// reorder surrounding text and let an admin craft a spec.host/displayName
@@ -35,7 +38,7 @@ export const DISPLAY_FIELD_MAX_LENGTH = 120
// legitimate in emoji sequences, so blanket-rejecting them would break valid
// display names. Confusable/invisible-glyph spoofing is out of scope here.
// eslint-disable-next-line no-control-regex
-const CONTROL_CHAR_RE = /[\x00-\x1f\x7f\u202a-\u202e\u2066-\u2069\u2028\u2029]/
+const CONTROL_CHAR_RE = /[\x00-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069\u2028\u2029]/
export interface FieldIssue {
field: string
diff --git a/control-api/test/routes.resourceFieldValidation.test.ts b/control-api/test/routes.resourceFieldValidation.test.ts
new file mode 100644
index 000000000..879502b0d
--- /dev/null
+++ b/control-api/test/routes.resourceFieldValidation.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from 'vitest'
+import { validateDisplayField } from '../src/routes/admin/resourceFieldValidation.js'
+
+describe('validateDisplayField', () => {
+ it('accepts a normal single-line label', () => {
+ expect(validateDisplayField('ok', 'f')).toBeNull()
+ })
+
+ it('skips an absent (undefined) field — presence is optional', () => {
+ expect(validateDisplayField(undefined, 'f')).toBeNull()
+ })
+
+ it('rejects a non-string value', () => {
+ const issue = validateDisplayField(42, 'field')
+ expect(issue).not.toBeNull()
+ expect(issue?.field).toBe('field')
+ expect(issue?.message).toContain('must be a string')
+ })
+
+ // R4-M4: the C1 control block (\x80-\x9f) must be rejected like C0/DEL.
+ describe('C1 control characters (R4-M4)', () => {
+ it('rejects U+0085 NEL — a line terminator that breaks the single-line label', () => {
+ const issue = validateDisplayField('ab…cd', 'field')
+ expect(issue).not.toBeNull()
+ expect(issue?.field).toBe('field')
+ expect(issue?.message).toContain('control')
+ })
+
+ it('rejects U+009B CSI — opens an ANSI escape sequence', () => {
+ const issue = validateDisplayField('ab›cd', 'field')
+ expect(issue).not.toBeNull()
+ expect(issue?.message).toContain('control')
+ })
+ })
+})