Hugging Face Transformers Regular Expression Denial of Service
        
  Moderate severity
        
          GitHub Reviewed
      
        Published
          May 19, 2025 
          to the GitHub Advisory Database
          •
          Updated Sep 25, 2025 
      
  
Description
        Published by the National Vulnerability Database
      May 19, 2025 
    
  
        Published to the GitHub Advisory Database
      May 19, 2025 
    
  
        Reviewed
      May 19, 2025 
    
  
        Last updated
      Sep 25, 2025 
    
  
A Regular Expression Denial of Service (ReDoS) exists in the
preprocess_string()function of thetransformers.testing_utilsmodule. In versions before 4.50.0, the regex used to process code blocks in docstrings contains nested quantifiers that can trigger catastrophic backtracking when given inputs with many newline characters. An attacker who can supply such input topreprocess_string()(or code paths that call it) can force excessive CPU usage and degrade availability.Fix: released in 4.50.0, which rewrites the regex to avoid the inefficient pattern. ([GitHub][1])
< 4.50.04.50.0References