All problems

Newlines in Maintenance Notes Forge Extra Audit Log Records

Level 2 · node · Security · CR/LF record-boundary injection through free-text audit notes

Scenario

A fictional facility inspection service records technicians' maintenance notes in an audit log. Each line contains a timestamp, operator, action, and note separated by pipe characters, with a newline separating records. Ordinary notes work, but a note containing a line feed or carriage return can make the stored text appear to contain additional records or disrupt terminal display. Trace the controller, writer, and repository so one submitted note always occupies exactly one audit record.

Requirements

Store CR and LF characters inside note text as visible escape sequences (backslash-r and backslash-n), not as control characters. Preserve both sequences in order for CRLF. Keep ordinary text and empty notes unchanged, and preserve the timestamp, operator, action fields and the repository's one-record-per-line contract. Do not depend on external services or the system clock.

Acceptance criteria

  • An ordinary maintenance note is stored on one line in the existing pipe-delimited format.
  • An empty note retains the field delimiters and line terminator.
  • Writing two ordinary notes produces exactly two log records.
  • An LF inside a note is stored as a literal backslash-n rather than a record separator.
  • A CR inside a note is stored as a literal backslash-r rather than a control character.
  • A note containing CRLF remains a single log record and retains both escape sequences in order.