Skip to content
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

[Security] Response size limitation #892

Open
ziaratban opened this issue Jul 10, 2021 · 1 comment
Open

[Security] Response size limitation #892

ziaratban opened this issue Jul 10, 2021 · 1 comment

Comments

@ziaratban
Copy link

Hi

How can i limit the size of the response from the client?

For example, after sending a client more than 100 bytes, the connection must be disconnected. (In one post)

@ziaratban
Copy link
Author

This is my web socket server:

$loop = \React\EventLoop\Factory::Create();
new \Ratchet\Server\IoServer(
    new \Ratchet\Http\HttpServer(
        new \Ratchet\WebSocket\WsServer(
            new class implements \Ratchet\MessageComponentInterface {

                public function OnOpen(\Ratchet\ConnectionInterface $con){
                }

                public function OnMessage(\Ratchet\ConnectionInterface $con, $message){
                    echo strlen($message); // How much?
                }

                public function OnClose(\Ratchet\ConnectionInterface $con){
                }

                public function OnError(\Ratchet\ConnectionInterface $con, \Exception $e){
                }
            }
        )
    ),
    new \React\Socket\SecureServer(
        new \React\Socket\Server('127.0.0.1:8989',$loop),
        $loop,
        array(
            'local_cert' => '...',
            'local_pk' => '...', 
            'allow_self_signed' => true,
            'verify_peer' => false
        )
    )
);

$loop->Run();

How many bytes of data can be received from the client?
How can I restrict this configuration?

If I can not manage this configuration, the attacker can send big data and take up memory (or I can not have precise management on the server).

I'm not familiar with reactphp source code, so I think it's related to:
https://github.com/reactphp/stream/blob/70d6e15d5f90730651558852c74fbb767fd9215b/src/ReadableResourceStream.php#L137

@clue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant