Skip to content

PWSH 7.2.1: invoke-webrequest hangs at: VERBOSE: received -byte response of content type text/plain #16685

Closed

Description

@penalvch-zz

Prerequisites

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/plain

Error 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.0

Visuals

No response

Activity

  1. added
    Needs-Triage
    on Jan 1, 2022
  2. iSazonov commented on Feb 7, 2022

    @iSazonov
    Collaborator
  3. ghost added
    In-PR
    on Feb 7, 2022
  4. PaulHigin commented on Feb 7, 2022

    @PaulHigin
    Contributor

    @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.

  5. ghost removed
    In-PR
    on Mar 30, 2022
  6. CarloToso commented on Jan 4, 2023

    @CarloToso
    Contributor

    Ilya (@iSazonov) This issue is fixed in PowerShell 7.4.0 preview 1

  7. iSazonov commented on Jan 4, 2023

    @iSazonov
    Collaborator

    Fixed in #17813

  8. ghost removed
    Needs-Triage
    on Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions