php/php-src — pull request #490 by rdlowrey (2013-10-11 21:14:13+00:00)
Title: Add "honor_server_ciphers" ssl context option to mitigate BEAST

#### Mitigating the BEAST TLS Vulnerability

The [BEAST][context] TLS attack vector was [first publicized in 2011][wiki-beast]. Mitigating this attack is relatively simple: servers have only to [prioritize ciphers][qualys-mitigation] that aren't susceptible to the attack. However, unless instructed otherwise, OpenSSL uses the client's preferences when negotiating the cipher. To prevent nefarious clients from prioritizing susceptible ciphers servers must configure SSL sessions using OpenSSL's `SSL_OP_CIPHER_SERVER_PREFERENCE` context option.

##### Proposed Solution

This patch adds a new boolean ssl context option, `"honor_server_ciphers"`, to mitigate BEAST vulnerabilities in encrypted stream servers.

##### Suggested Usage

```php
[
'local_cert' => '/path/to/cert.pem',
'max_handshake_rate' => 0,
'disable_compression' => TRUE,
'ciphers' => '',
'honor_server_ciphers' => TRUE
]]);
$server = stream_socket_server($bindTo, $errNo, $errStr, $flags, $ctx);
```

##### Other Considerations

It's not really possible to include tests for this functionality without adding new functions to retrieve the negotiated cipher from an encrypted socket stream. I don't generally feel like creating functions solely for use in testing things is a good idea, so there are no .phpt tests included. I may PR a new function to get meta information about the SSL session in the future, though. In such a case I'll go ahead and add tests for this scenario.

[context]: http://contextis.com/research/blog/server-technologies-https-beast-attack/
[wiki-beast]: http://en.wikipedia.org/wiki/Transport_Layer_Security#BEAST_attack
[qualys-mitigation]: https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating-the-beast-attack-on-tls