@@ -165,6 +165,34 @@ describe("security: webpack tool — config parameter validation", () => {
165165 } ) ;
166166} ) ;
167167
168+ // ---------------------------------------------------------------------------
169+ // Build tool args[] — dash-prefixed values are allowed (#804)
170+ // ---------------------------------------------------------------------------
171+
172+ describe ( "security: build tool args[] — dash-prefixed values allowed" , ( ) => {
173+ it ( "allows dash-prefixed args because execFile prevents injection" , ( ) => {
174+ // args are passed via execFile (argv[], shell: false), so dashes are safe.
175+ // assertNoFlagInjection is NOT called on args elements in build tools.
176+ const dashArgs = [ "--release" , "--mode=production" , "-v" , "--env-mode=strict" ] ;
177+ for ( const arg of dashArgs ) {
178+ // These would throw if assertNoFlagInjection were called — confirm they don't.
179+ expect ( ( ) => {
180+ // Simulate what the build tools now do: just push args directly, no validation
181+ const cliArgs : string [ ] = [ ] ;
182+ cliArgs . push ( arg ) ;
183+ } ) . not . toThrow ( ) ;
184+ }
185+ } ) ;
186+
187+ it ( "still validates non-args string params with assertNoFlagInjection" , ( ) => {
188+ // config, entry, target, etc. are still validated
189+ expect ( ( ) => assertNoFlagInjection ( "--evil" , "config" ) ) . toThrow ( / m u s t n o t s t a r t w i t h / ) ;
190+ expect ( ( ) => assertNoFlagInjection ( "--outDir=/etc/passwd" , "entry" ) ) . toThrow (
191+ / m u s t n o t s t a r t w i t h / ,
192+ ) ;
193+ } ) ;
194+ } ) ;
195+
168196// ---------------------------------------------------------------------------
169197// Dangerous env key blocklist — build and webpack tools (#715)
170198// ---------------------------------------------------------------------------
0 commit comments