News for hackers. Stuff that matters.
Re:PHP filter_var shenanigans by Lazare on Monday March 28, 2022 @01:04AM (#30827309)
I wonder if this is actually exploitable in the wild or not?

A 4GB request is a very large amount of data indeed.

Re:PHP filter_var shenanigans by jamesfinlayson on Monday March 28, 2022 @01:30AM (#30827420)
As a sibling comment pointed out, PHP has max_execution_time which I think defaults to 30 seconds, but I'd guess plenty of people have set it to unlimited to work around some problem or other.

A beefy server should be able to process 4GB of data within 30 seconds though I suppose.

Re:PHP filter_var shenanigans by apocalyptic0n3 on Monday March 28, 2022 @11:39AM (#30831659)
max_execution_time starts when the entire request has been received (or, more accurately, once PHP script execution has begun). Upload times don't trigger it to start.

If I recall correctly, max_input_time includes time taken to copy the file to the tmp directory and to parse the file for metadata, but not the upload time either (it does start prior to max_execution_time though). This value is set to -1 by default meaning it uses the value from max_execution_time instead.

You're more likely to run into Apache, Nginx, or PHP FPM timeouts. I can't remember exactly which timeout, but I remember there is one in Apache or FPM that is affected by upload time.

Re:PHP filter_var shenanigans by speedgoose on Monday March 28, 2022 @06:38AM (#30829095)
For sure. A recent smartphone can.
Re:PHP filter_var shenanigans by viraptor on Monday March 28, 2022 @01:46AM (#30827499)
However if the input comes from the request body, 4GB of "aaaaa...." compresses exceptionally well. Http3 can compress headers too.
Re:PHP filter_var shenanigans by Dylan16807 on Monday March 28, 2022 @02:56AM (#30827858)
I don't think I would say "exceptionally well" as a rule. Compression algorithms often leave a lot on the table for very long repetitions. For example, gzip can only encode repetitions up to 258 bytes, and the absolute best case for encoding that costs 2 output bits. And then a 4GB file of the same character over and over compresses to a 4MB file primarily made of... the same character over and over.
Re:PHP filter_var shenanigans by viraptor on Monday March 28, 2022 @06:13AM (#30828988)
I think that classifies as exceptionally well. You get 1000x compression and when trying to send a compressed payload, the issue of "the server may time out the connection" pretty much goes away. 4MB is trivial to send from almost anywhere - to hit the 30s timeout, you'd need to go slower than 137KB/s.
Re:PHP filter_var shenanigans by Dylan16807 on Monday March 28, 2022 @01:25PM (#30833028)
It could trivially enable millions or billions to 1 compression, though. It just needs the option of a longer length field. With even a single megabyte of repeated data, it has to split it into four thousand chunks. That's not exceptional in my book.

I'll call it exceptional when it can encode any real-drive-size repeated-character file into the size of a tweet.

Re:PHP filter_var shenanigans by bawolff on Monday March 28, 2022 @05:29AM (#30828782)
I also sort of wonder what happens if you try and put > 4gb on the commandline. Surely there is a limit for max size of commandline arguments.
Re:PHP filter_var shenanigans by tyingq on Monday March 28, 2022 @08:20AM (#30829692)
For Linux, it's ARG_MAX, so

  $ getconf ARG_MAX
  2097152
It's driven by some formula related to max stack size (ulimit -Ss), but capped at 6 MiB.

https://mina86.com/2021/the-real-arg-max-part-1/

Re:PHP filter_var shenanigans by spacemanmatt on Monday March 28, 2022 @08:17AM (#30829664)
From vague experience, the CLI limits you to a few kilobytes.