New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault when POST large file with vibe.d 0.8.1 #1966

Closed
tosttost opened this Issue Oct 28, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@tosttost
Contributor

tosttost commented Oct 28, 2017

dub.json:
{ "name": "foo", "authors": [ "-" ], "dependencies": { "vibe-d": "0.8.1" }, "subConfigurations": { "vibe-d:http": "notls" }, "versions": ["VibeNoSSL"], "description": "A simple vibe.d server application.", "copyright": "Copyright © 2017, -", "license": "MIT" }
(the notls/VibeNoSSL settings are only workarounds due to arch linux and openssl 1.1).

app.d (unchanged from "dub init foo -t vibe.d"):

import vibe.vibe;

void main()
{
	auto settings = new HTTPServerSettings;
	settings.port = 8080;
	settings.bindAddresses = ["::1", "127.0.0.1"];
	listenHTTP(settings, &hello);
	logInfo("Please open http://127.0.0.1:8080/ in your browser.");
	runApplication();
}

void hello(HTTPServerRequest req, HTTPServerResponse res)
{
	res.writeBody("Hello, World!");
}

compile and run.

curl -F "bar=@some_large_file" localhost:8080

and the server segfaults.

Valgrind:

==6220== Invalid read of size 8
==6220==    at 0x5F59B5: _D4vibe6stream10operations113__T14readUntilSmallTS4vibe5utils5array25__T13AllocAppenderHTAhThZ13AllocAppenderTC4vibe4core6stream11InputStreamZ14readUntilSmallFNfC4vibe4core6stream11InputStreamKS4vibe5utils5array25__T13AllocAppenderHTAhThZ13AllocAppenderxAhmZv (../../../.dub/packages/vibe-d-0.8.1/vibe-d/stream/vibe/stream/operations.d:362)
==6220==    by 0x5F593A: _D4vibe6stream10operations107__T9readUntilTS4vibe5utils5array25__T13AllocAppenderHTAhThZ13AllocAppenderTC4vibe4core6stream11InputStreamZ9readUntilFNfC4vibe4core6stream11InputStreamKS4vibe5utils5array25__T13AllocAppenderHTAhThZ13AllocAppenderxAhmZv (../../../.dub/packages/vibe-d-0.8.1/vibe-d/stream/vibe/stream/operations.d:142)
==6220==    by 0x5F58DC: _D4vibe6stream10operations106__T8readLineTS4vibe5utils5array25__T13AllocAppenderHTAhThZ13AllocAppenderTC4vibe4core6stream11InputStreamZ8readLineFNfC4vibe4core6stream11InputStreamKS4vibe5utils5array25__T13AllocAppenderHTAhThZ13AllocAppendermAyaZv (../../../.dub/packages/vibe-d-0.8.1/vibe-d/stream/vibe/stream/operations.d:56)
==6220==    by 0x5F5896: _D4vibe6stream10operations45__T8readLineTC4vibe4core6stream11InputStreamZ8readLineFNfC4vibe4core6stream11InputStreammAyaC3std12experimental9allocator10IAllocatorZAh (../../../.dub/packages/vibe-d-0.8.1/vibe-d/stream/vibe/stream/operations.d:41)
==6220==    by 0x69C086: _D4vibe4inet7webform56__T18parseMultiPartFormTC4vibe4core6stream11InputStreamZ18parseMultiPartFormFKS4vibe5utils14dictionarylist37__T14DictionaryListTAyaVbi1Vmi16Vbi0Z14DictionaryListKS4vibe5utils14dictionarylist61__T14DictionaryListTS4vibe4inet7webform8FilePartVbi1Vmi0Vbi0Z14DictionaryListAyaC4vibe4core6stream11InputStreammZ9__lambda7MFNeZAya (../../../.dub/packages/vibe-d-0.8.1/vibe-d/stream/vibe/stream/operations.d:36)
==6220==    by 0x69BEFF: _D4vibe4inet7webform56__T18parseMultiPartFormTC4vibe4core6stream11InputStreamZ18parseMultiPartFormFNfKS4vibe5utils14dictionarylist37__T14DictionaryListTAyaVbi1Vmi16Vbi0Z14DictionaryListKS4vibe5utils14dictionarylist61__T14DictionaryListTS4vibe4inet7webform8FilePartVbi1Vmi0Vbi0Z14DictionaryListAyaC4vibe4core6stream11InputStreammZv (../../../.dub/packages/vibe-d-0.8.1/vibe-d/inet/vibe/inet/webform.d:139)
==6220==    by 0x69B7A1: _D4vibe4inet7webform13parseFormDataFNfKS4vibe5utils14dictionarylist37__T14DictionaryListTAyaVbi1Vmi16Vbi0Z14DictionaryListKS4vibe5utils14dictionarylist61__T14DictionaryListTS4vibe4inet7webform8FilePartVbi1Vmi0Vbi0Z14DictionaryListAyaC4vibe4core6stream11InputStreammZb (../../../.dub/packages/vibe-d-0.8.1/vibe-d/inet/vibe/inet/webform.d:53)
==6220==    by 0x5FC321: _D4vibe4http6server17HTTPServerRequest17parseFormAndFilesMFNfZv (../../../.dub/packages/vibe-d-0.8.1/vibe-d/http/vibe/http/server.d:938)
==6220==    by 0x5FC3AE: _D4vibe4http6server17HTTPServerRequest5filesMFNcNdNfZS4vibe5utils14dictionarylist61__T14DictionaryListTS4vibe4inet7webform8FilePartVbi1Vmi0Vbi0Z14DictionaryList (../../../.dub/packages/vibe-d-0.8.1/vibe-d/http/vibe/http/server.d:946)
==6220==    by 0x60217B: _D4vibe4http6server13handleRequestFNfC4vibe4core6stream6StreamC4vibe4core3net13TCPConnectionC4vibe4http6server14HTTPListenInfoKC4vibe4http6server18HTTPServerSettingsKbMC3std12experimental9allocator10IAllocatorZb (../../../.dub/packages/vibe-d-0.8.1/vibe-d/http/vibe/http/server.d:2192)
==6220==    by 0x600804: _D4vibe4http6server20handleHTTPConnectionFNfC4vibe4core3net13TCPConnectionC4vibe4http6server14HTTPListenInfoZ9__lambda3MFNeZv (../../../.dub/packages/vibe-d-0.8.1/vibe-d/http/vibe/http/server.d:1931)
==6220==    by 0x6006D3: _D4vibe4http6server20handleHTTPConnectionFNfC4vibe4core3net13TCPConnectionC4vibe4http6server14HTTPListenInfoZv (../../../.dub/packages/vibe-d-0.8.1/vibe-d/http/vibe/http/server.d:1923)
==6220==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

This does not happen with vibe.d 0.7.32.
Setting maxRequestSize to a sufficient large value fixes the issue, but this can probably be used as a denial-of-service attack against server that do not expect large file uploads.

@s-ludwig s-ludwig closed this in b2e27e4 Nov 5, 2017

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