Skip to content

[Correctness] NativeMethods.cs — Regex character class [@!-] parsed as ASCII range, allows unintended characters #563

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Critical

File: src/Servy.Core/Native/NativeMethods.cs
Lines: 386–399

Description:
The username validation regex @"^(?:[\w\s\.-]+|\.)\[\w\s\.@!-]+\$?$" contains the character class [@!-] where !- is interpreted as a character range from ! (ASCII 33) to - (ASCII 45). This inadvertently permits characters ", #, $, %, &, ', (, ), *, +, , in the username field. While Windows usernames cannot actually contain most of these characters, this is a subtle regex bug that could allow malformed input to pass validation.

Suggested fix:
Escape the hyphen in the character class: [@!\-] or move it to the end of the class: [@!-][@!\x2D] or [!@-].

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions