Repository navigation
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
While attempting to download a file from the following URL, invoke-webrequest hangs seemingly indefinitely with no indication of why. The 'Reading Response' displays, so it seems to actually download the data, but just hangs after doing so. The PWSH window is not responsive to Ctrl+C.
NOTE: If testing the below, replace the useragent string with a valid 'Company Name' and 'email address' as per below U.S. sec.gov Webmaster FAQs. When I ran the command I use my own email address with my own custom string (changing the user agent string to something completely different didn't change anything):
https://www.sec.gov/os/webmaster-faq#developers
However, the following equivalent Windows PowerShell 5.1 command works perfectly so seems regression:
$test=invoke-webrequest -uri 'https://www.sec.gov/Archives/edgar/data/0000008177/000156761917000512/0001567619-17-000512.txt' -useragent 'Private Investor [email protected]' -usebasicparsing -method get -verbose
PS C:\WINDOWS\system32>
WORKAROUND on Windows only:
$test=& 'powershell.exe' "(invoke-webrequest -uri 'https://www.sec.gov/Archives/edgar/data/0000008177/000156761917000512/0001567619-17-000512.txt' -useragent 'Private Investor [email protected]' -usebasicparsing -method get).content"
Expected behavior
PS C:\Windows\System32>$test=invoke-webrequest -uri 'https://www.sec.gov/Archives/edgar/data/0000008177/000156761917000512/0001567619-17-000512.txt' -useragent 'Private Investor [email protected]' -SkipHeaderValidation -method GET -verbose
PS C:\Windows\System32>Actual behavior
PS C:\Windows\System32>$test=invoke-webrequest -uri 'https://www.sec.gov/Archives/edgar/data/0000008177/000156761917000512/0001567619-17-000512.txt' -useragent 'Private Investor [email protected]' -SkipHeaderValidation -method GET -verbose
VERBOSE: GET with 0-byte payload
VERBOSE: received -byte response of content type text/plainError details
No response
Environment data
$PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Activity
penalvch-zz commentedon Feb 5, 2022
Same problem with:
https://www.sec.gov/Archives/edgar/data/0000810509/000143774919022151/0001437749-19-022151.txt
iSazonov commentedon Feb 7, 2022
Travis Plunk (@TravisEz13) Paul Higinbotham (@PaulHigin) Maybe for WG-Security. Infinite cycle in Regex
PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs
Line 435 in a5d41c2
PaulHigin commentedon Feb 7, 2022
@WG-Security
WG-Security group looked at this and there is potential for infinite recursion on the regex (s_metaexp) string (line 414) and DOS attack.
There should be fuzz testing along with a fix, and this can be done by using text files for fuzzing source.
Note that dotNet has added code to remove some potential infinite recursions, when possible. But we shouldn't count on it.
CarloToso commentedon Jan 4, 2023
Ilya (@iSazonov) This issue is fixed in
PowerShell 7.4.0 preview 1iSazonov commentedon Jan 4, 2023
Fixed in #17813