When you see entries like Invalid method in request \\x16\\x03\\x01
or garbled strings in Apache's error_log, you're witnessing failed SSL/TLS handshake attempts. These binary-looking sequences are actually SSL/TLS protocol headers, not HTTP requests.
// Example of what the raw byte sequence represents:
\x16\x03\x01\x00\xXX // SSL Record Header (XX = length)
\x01\x00\x00\xXX // Handshake Header
This occurs when:
- A client attempts SSL/TLS negotiation on a plain HTTP port
- Bots/scanners probing for vulnerable SSL services
- Misconfigured clients trying HTTPS on HTTP ports
To analyze these requests in detail, enable mod_dumpio:
# In httpd.conf or virtual host:
LogLevel dumpio:trace7
DumpIOInput On
DumpIOOutput On
Sample output interpretation:
# SSLv3/TLS Client Hello:
[timestamp] [dumpio:trace7] mod_dumpio: dumpio_in (data-HEAP): 16 03 01 00 b3 01 00 00 af 03 03 [...]
For security-conscious setups:
# Create a separate SSL-only virtual host
<VirtualHost *:443>
SSLEngine on
# Redirect HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
For debugging:
# Use openssl to simulate the handshake
openssl s_client -connect yourserver:443 -debug
For servers handling both HTTP and HTTPS, implement protocol detection:
# In mod_rewrite rules
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST|PUT|DELETE)$
RewriteRule .* - [F]
Finding gibberish like \x16\x03\x01
in your Apache error logs typically indicates SSL/TLS handshake attempts. These aren't actual errors, but rather connection attempts that don't complete the HTTP protocol handshake.
The sequence \x16\x03\x01
breaks down as:
\x16 - Content Type (22 = Handshake) \x03 - SSL Version Major (3) \x01 - SSL Version Minor (1) = TLS 1.0
This is the start of a TLS ClientHello message, not an HTTP request.
You'll see this when:
1. Port scanners hitting port 443 2. Misconfigured clients attempting TLS on HTTP ports 3. Legacy systems using outdated protocols 4. Botnet probing activity
For Apache 2.4+, add this to your SSL virtual host:
<VirtualHost *:443>
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite HIGH:!aNULL:!MD5:!RC4:!3DES
SSLHonorCipherOrder on
ErrorLog ${APACHE_LOG_DIR}/ssl_error.log
LogLevel warn
</VirtualHost>
Create a separate error log for SSL handshake failures:
CustomLog logs/ssl_access_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x"
ErrorLog logs/ssl_error_log
LogLevel info:ssl_engine:error
Use mod_evasive to block repeated handshake failures:
<IfModule mod_evasive24.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 60
</IfModule>
Create a log analysis script to track these events:
#!/usr/bin/perl
use strict;
my %client_counts;
while(<>) {
if(/Invalid method.*\\x16\\x03\\x01.*client (\d+\.\d+\.\d+\.\d+)/) {
$client_counts{$1}++;
}
}
foreach my $ip (sort {$client_counts{$b} <=> $client_counts{$a}} keys %client_counts) {
print "$ip: $client_counts{$ip} attempts\n";
}