AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

PIIMiddleware URL Detector Falsely Flags Dotted Identifiers, Versions, And Ratios As URLs

The bare URL pattern in detect_url incorrectly matches patterns like 'Node.js/Express', '1.5/2.0', and 'python3.12/site-packages', leading to redaction or blocking of non-URL content.

highConfidence 90%LangChainAffected V1.4.0

Origin Analysis

The bare URL regex and its acceptance heuristic are too permissive; any label.label/anything combination with a dot in the host passes the check, without validating the TLD or context.
Run the provided reproduction script using PIIMiddleware with 'url' strategy; observe false detections for the listed samples.

Fixing Code Block

Edge Case Audit

This hotfix may miss legitimate bare URLs with numeric labels (rare) or two-letter TLDs without www. (e.g., example.io/path). Test thoroughly. Rollback by reverting the change to the previous permissive check. The function is stateless, so no concurrency issues, but ensure compatibility with langchain_core versions.

Ecosystem Topology