Detecting malware even when it is encrypted - Machine Learning for network HTTPS analysis
František Střasák
BruCON 0x09 · Day 1
Overview
This talk, presented by František Střasák at BruCON 2017, delves into a critical challenge in modern cybersecurity: detecting malicious activity embedded within encrypted HTTPS traffic without resorting to decryption. As a significant and growing portion of internet traffic, HTTPS presents a formidable barrier to traditional security analysis methods, which often rely on inspecting the unencrypted payload. Střasák, a student from the Czech Technical University, outlines his research, supervised by Sebastian Garcia, on leveraging machine learning (ML) algorithms and publicly available metadata from HTTPS connections to identify malware.

Key moments
- 2:00 The growing problem of encrypted malware traffic
- 4:30 Detecting malware without TLS decryption
- 10:45 Comprehensive dataset for HTTPS malware analysis
- 14:30 Extracting features from Bro IDS logs
- 22:30 Using certificate properties as detection features
- 35:30 Realistic experiment results and accuracy
- 37:00 Identification of most important detection features
- 40:30 Current limitations and future research directions
Detecting malware even when it is encrypted - Machine Learning for network HTTPS analysis
Speakers: František Střasák, Student, Czech Technical University
Conference: BruCON
YouTube: https://www.youtube.com/watch?v=jlEbsXTKGcQ
Overview
This talk, presented by František Střasák at BruCON 2017, delves into a critical challenge in modern cybersecurity: detecting malicious activity embedded within encrypted HTTPS traffic without resorting to decryption. As a significant and growing portion of internet traffic, HTTPS presents a formidable barrier to traditional security analysis methods, which often rely on inspecting the unencrypted payload. Střasák, a student from the Czech Technical University, outlines his research, supervised by Sebastian Garcia, on leveraging machine learning (ML) algorithms and publicly available metadata from HTTPS connections to identify malware.
The motivation for this research is compelling. While HTTPS ensures privacy and integrity, malware authors increasingly exploit its encryption to evade detection. Traditional solutions like TLS inspection (or SSL inspection) involve decrypting, analyzing, and re-encrypting traffic, which introduces significant costs, performance overheads, and, crucially, compromises the very privacy HTTPS aims to protect. Střasák's work explores a privacy-preserving alternative, focusing on extracting non-payload features from the TLS handshake and certificate information that can serve as indicators of compromise.
The importance of this research lies in its potential to offer a scalable and privacy-respecting approach to network security in an increasingly encrypted world. By demonstrating that meaningful insights can be gleaned from metadata alone, the project lays groundwork for future detection systems that can adapt to evolving threat landscapes without sacrificing user privacy or incurring the heavy operational burdens of full decryption. Although the research acknowledges that its initial results, while promising, did not yet achieve the high accuracy and low false positive rates required for real-world deployment, it clearly identifies key features and methodologies that warrant further investigation.
Background
▶ Watch: The growing problem of encrypted malware traffic (2:00)
The ubiquitous nature of HTTPS (Hypertext Transfer Protocol Secure) is a defining characteristic of the modern internet. Comprising over half of global web traffic, and up to two-thirds for users of browsers like Google Chrome, HTTPS encrypts data in transit using TLS (Transport Layer Security) or its predecessor, SSL (Secure Sockets Layer). The primary goals of HTTPS are twofold: first, to verify that the client is communicating with the legitimate server and not an imposter; and second, to ensure the privacy and integrity of the communication, meaning nobody can eavesdrop on or tamper with the data exchanged between the client and server.
The TLS handshake is a crucial initial phase of any HTTPS connection, involving three main parts:
- Client and Server Hello: The client initiates the connection by sending a "Client Hello" message, proposing various parameters like supported TLS/SSL versions and cipher suites. The server responds with a "Server Hello," selecting the mutually preferred parameters.
- Certificate Exchange: The server sends its public certificate to the client. This certificate, issued by a Certificate Authority (CA), contains the server's public key and identity information. The client then verifies the certificate's authenticity by checking its chain of trust, which typically involves intermediate certificates ultimately signed by a trusted root certificate pre-installed in the client's browser or operating system.
- Key Exchange: Once the certificate is validated, the client generates a symmetric encryption key, encrypts it using the server's public key (from the certificate), and sends it to the server. Only the server, possessing the corresponding private key, can decrypt this symmetric key. This symmetric key is then used for the secure and efficient encryption of all subsequent application data.
A critical distinction highlighted in the talk is that "privacy doesn't mean security." The green padlock icon in a browser merely indicates that the communication channel is encrypted and authenticated; it does not guarantee that the content itself is benign or that the server is not malicious. Modern malware has increasingly adapted to this reality, with reports suggesting anywhere from 10% to 40% of malware now leveraging HTTPS for its command and control (C2) or data exfiltration. The core problem for defenders is that the payload data—the actual content being transmitted—is encrypted, rendering most traditional signature-based and deep packet inspection (DPI) techniques ineffective, as these methods rely on examining the unencrypted data.
One common solution to this problem is TLS inspection, where an intermediary device (e.g., a proxy server) sits between the client and server, decrypting the traffic, scanning it for malicious content, and then re-encrypting it before forwarding. While this allows the use of classic detection methods, it comes with significant drawbacks:
- Cost and Complexity: TLS inspection devices can be expensive and computationally demanding.
- Performance Overhead: Decryption and re-encryption add latency and consume resources.
- Privacy Concerns: Most importantly, TLS inspection fundamentally violates the privacy principle of HTTPS by performing a Man-in-the-Middle (MitM) attack, albeit a sanctioned one.
The research presented here proposes an alternative: detecting HTTPS malware traffic without decryption. This approach necessitates the discovery of new, publicly available features derived from the metadata of the HTTPS connection and certificates, which can then be fed into machine learning algorithms. The ultimate goal is to achieve high accuracy with a low false positive rate (FPR) and false negative rate (FNR), enabling effective malware detection while preserving the privacy inherent to HTTPS.
Key terms defined in the talk for evaluation metrics include:
- True Positive (TP): Predicted malware, actual malware.
- True Negative (TN): Predicted normal, actual normal.
- False Positive (FP): Predicted malware, actual normal (a "false alarm").
- False Negative (FN): Predicted normal, actual malware (a "missed detection").
- Accuracy: (TP + TN) / (TP + TN + FP + FN) – The proportion of correctly predicted instances.
- False Positive Rate (FPR): FP / (FP + TN) – The proportion of normal traffic incorrectly classified as malware.
- False Negative Rate (FNR): FN / (FN + TP) – The proportion of malware traffic incorrectly classified as normal.
Key Findings
▶ Watch: Comprehensive dataset for HTTPS malware analysis (10:45)
The research, while identifying promising avenues, ultimately concluded that its initial implementation did not fully achieve the goal of detecting HTTPS malware with sufficiently high accuracy and low false positive rates for immediate real-world deployment. The achieved accuracy generally ranged from 90% to 95%, which, though seemingly high, was accompanied by false positive rates (FPR) of 5% to 10%. In a real-world network with millions of legitimate HTTPS connections, even a 5% FPR would generate an unmanageable number of false alarms, rendering the system impractical.
Despite not reaching production-ready performance, the study yielded several significant findings:
- Identified Important Features: The research successfully identified a set of 40 high-level features derived from HTTPS metadata that contribute significantly to distinguishing between normal and malicious traffic. The most influential features, in order of importance, were:
- Certificate Validity Length: The duration for which a certificate is valid (e.g., 25 days, 2 years, 10 years). Malware often uses certificates with unusually short or long validity periods.
- Inbound and Outbound Packet Counts: The number of packets exchanged during the connection, including their mean and standard deviation.
- Certificate Validity During Capture: A ratio indicating if the certificate was valid at the time the traffic was captured.
- Duration: The mean and standard deviation of the connection's duration.
- Number of Domain Names in Subject Alternative Names (SAN): The list of domains a certificate is valid for. Malware certificates often list an unusually high or low number of domains.
- SSL/TLS Version: Malware sometimes uses older, less secure versions of SSL/TLS.
- Periodicity: The "second-level time difference" between consecutive SSL aggregations within a connection unit, indicating regular or irregular communication patterns.
- Malware Certificate Characteristics: The study observed that 50% of certificates used by malware were found in the Alexa Top 100 websites, compared to only 30% for normal traffic (though this was influenced by the normal dataset's geographical origin). This suggests malware often tries to blend in by using certificates associated with popular domains. Interestingly, the study also found that most certificates used by malware were "normal" and not inherently broken or misconfigured, indicating that malware operators are adept at acquiring legitimate-looking certificates.
- Data Scarcity and Overfitting: Learning curves for the XGBoost model indicated that more training data would likely lead to better performance, suggesting the current dataset, while substantial (375 GB), was still insufficient to fully train the model for real-world robustness. The Random Forest model, conversely, showed signs of overfitting, where it performed exceptionally well on training data but struggled with unseen data.
- Algorithm Performance: XGBoost consistently outperformed other tested machine learning algorithms, including Random Forest, simple Neural Networks, and Support Vector Machines (SVM). Neural Networks and SVMs, in particular, yielded significantly worse results, with accuracies around 80%, which the researchers attributed potentially to the structure of the data requiring further investigation.
In summary, while the research didn't deliver a ready-to-deploy solution, it provided invaluable insights into the types of metadata features that hold predictive power for HTTPS malware detection and highlighted the challenges and future directions for this critical area of cybersecurity.
Technical Deep Dive
▶ Watch: Using certificate properties as detection features (22:30)
The technical core of this research revolves around the meticulous collection of HTTPS traffic, the extraction and engineering of non-payload features using Bro IDS (now known as Zeek), and the application of various machine learning algorithms.
Data Set Construction
The foundation of any machine learning project is its data set. For this research, the data set was exclusively composed of HTTPS traffic, meticulously labeled as either "malware" or "normal." The total data set size was substantial, encompassing 375 gigabytes of PCAP files, representing nearly 2 million TLS flows and utilizing 8,600 unique certificates. The data was assembled from several sources:
- CTU-14 Data Set: A publicly available data set from the Czech Technical University, containing both malware and normal captures, generated from research on botnet detection.
- MCFP Data Set: Another public data set from the Malware Capture Facility Project, providing additional malware and normal captures.
- Custom Normal Captures: To augment the normal traffic, the researchers generated their own captures by simulating typical user behavior. This involved three days of actively browsing 1,000 top Alexa websites, creating accounts on platforms like Google, Facebook, and Twitter, and interacting with them.
- Private University Traffic: A private data set consisting of real-world normal traffic from the university network, ensuring a more realistic representation of benign user activity. The private nature was due to the sensitive content of real user data.
The decision to make most of the data set public underscores the research's commitment to verifiability and reproducibility.
Feature Extraction with Bro IDS
The raw PCAP files were processed using Bro IDS, an open-source network analysis framework capable of generating detailed log files from network traffic. Bro's ability to parse various protocols and record extensive metadata was crucial for this project. Three specific Bro log files were utilized:
conn.log: This log provides information about network connections, including TCP, UDP, and ICMP. Key data points extracted included:
- Source and destination IP addresses.
- Number of inbound and outbound packets.
- Number of inbound and outbound bytes.
- Unix timestamp of the capture.
- Connection state (e.g., established, not established).
- Duration of the connection.
ssl.log: This log captures details about the SSL/TLS handshake. Information extracted included:
- TLS/SSL version used.
- Chosen cipher suite.
- Server Name Indication (SNI).
- Certificate path (chain of trust).
x509.log: This log provides detailed information about the X.509 certificates exchanged during the TLS handshake. Extracted features included:
- Serial number of the certificate.
- Common Name (CN) of the certificate.
- Validity period (start and end dates).
- Public key signature algorithm.
- Issuer of the certificate.
- Subject Alternative Names (SANs): A list of domains or IP addresses for which the certificate is valid.
A significant advantage of Bro's logs is their interconnection. Each log entry often contains a unique key that links it to corresponding entries in other logs (e.g., a conn.log entry for a TLS connection would link to its ssl.log and x509.log counterparts), allowing for a holistic view of each HTTPS session.
Feature Engineering
From these raw Bro logs, the researchers engineered higher-level features in a multi-step process:
- SSL Aggregation: Information from the
conn.log,ssl.log, andx509.logfor a single TLS connection was combined into an "SSL aggregation." - SSL Connect Unit: Multiple SSL aggregations that shared the same source IP, destination IP, destination port, and protocol were grouped into an "SSL Connect Unit." This unit represents a series of related connections to a specific service, independent of exact timing. Each SSL Connect Unit became a single data point for the machine learning models.
- High-Level Features (40 total): From each SSL Connect Unit, 40 high-level features were computed. These features often involved statistical aggregations (mean, standard deviation, ratios) across the individual SSL aggregations within a unit. Examples of these features include:
- Number of SSL aggregations: Simple count within a unit.
- Mean and Standard Deviation of Duration: Aggregating connection durations.
- Mean and Standard Deviation of Packet/Byte Counts: Aggregating inbound/outbound traffic volumes.
- Ratio of Established vs. Not Established States: Indicating connection success rates.
- Mean and Standard Deviation of Second-Level Time Difference: Analyzing the periodicity or irregularity of connections within a unit. For instance, if connections occur at 0, 15, and 16 minutes, the differences are 15 and 1 minute, which provides a pattern.
- Ratio of SSL/TLS Versions: Prevalence of different protocol versions.
- Number of Unique Certificates: How many distinct certificates were observed within a connect unit (usually one, but sometimes more).
- Mean and Standard Deviation of Validity Length: The total duration a certificate is valid for.
- Ratio of Certificate Validity During Capture: This feature calculates
(capture_time - cert_start_time) / cert_validation_length. It indicates how "fresh" or "old" a certificate was at the time of capture, relative to its total lifespan. - Weighted Mean of Public Keys: A numerical representation derived from the public key.
- Mean and Standard Deviation of Certificate Path Length: The number of certificates in the chain of trust.
- Mean and Standard Deviation of Domain Names in SAN: The count of alternative domain names listed in the certificate.
- Ratio of Common Name in SAN DNS: Checks if the primary domain name matches one of the Subject Alternative Names.
After feature engineering, the data was normalized before being fed into the machine learning algorithms. The final data model consisted of over 46,000 SSL Connect Units for normal traffic and 8,000 for malware traffic, each with 40 features and a label.
Machine Learning Algorithms
The research experimented with several machine learning algorithms:
- XGBoost (Extreme Gradient Boosting): Used with logistic regression. This algorithm showed the best performance among those tested. The researchers noted that while some parameter tuning was done, exhaustive optimization was not performed.
- Random Forest: A classifier based on an ensemble of decision trees. It performed reasonably well but exhibited signs of overfitting in the learning curves.
- Neural Network: A simple neural network with Adam (Adaptive Moment Estimation) optimization. This algorithm yielded poor results, with accuracy around 80%, suggesting it might not be well-suited for the data structure or required more sophisticated architecture and tuning.
- SVM (Support Vector Machine): Used with an RBF (Radial Basis Function) kernel. Similar to the Neural Network, SVM also showed poor performance (around 80% accuracy).
Experiments and Results
The experiments were structured to evaluate the models under different conditions, measuring accuracy, FPR, FNR, sensitivity, and F1-score.
- Data Splitting: The data set was split into
nsubsets. Each subset contained unique malware for testing, ensuring that the models were evaluated on previously unseen malware samples. For each subset, data was further divided into training (for cross-validation and learning) and testing (for final evaluation). - Cross-Validation: 10-fold cross-validation was applied to the training data to ensure robust model evaluation and hyperparameter tuning.
- Learning Curves: Analysis of learning curves (training score vs. cross-validation score) revealed insights into model bias and variance. For XGBoost, the curves indicated no significant overfitting but a need for more data to achieve better generalization. Random Forest, however, showed a notable gap between training and cross-validation scores, suggesting overfitting to the training data.
Experiment 1: Balanced Data
- Setup: Two subsets were used. Training and testing data were balanced (50% normal, 50% malware). This scenario is unrealistic but helps understand model behavior without class imbalance.
- Results:
- XGBoost: Cross-validation accuracy: 91.5%; Testing accuracy: 92%; FPR: 7.5%; FNR: 8.5%.
- Random Forest: Cross-validation accuracy: 90%; Testing accuracy: 90%; FPR: 10.3%; FNR: 19%.
Experiment 2: Realistic Imbalance
- Setup: Eight subsets were used. Training data was moderately imbalanced (40% malware, 60% normal). Crucially, testing data was highly imbalanced, reflecting real-world conditions (3% malware, 97% normal). Acknowledged issue: testing data often exceeded training data, indicating data scarcity.
- Results:
- XGBoost: Cross-validation accuracy: 92.45%; Testing accuracy: 94%; FPR: 5%; FNR: 10%.
- Random Forest: Cross-validation accuracy: 91%; Testing accuracy: 95%; FPR: 8%; FNR: 14%.
While the accuracy numbers in the realistic scenario look high, the corresponding false positive rates (5-10%) were deemed too high for practical deployment. A 5% FPR means 5 out of every 100 legitimate connections would be flagged as malicious, leading to alert fatigue in a high-volume network. The research concluded that despite the promising features and methodology, more work is needed to reduce FPR to an acceptable level for production environments.
Demo / Proof of Concept
▶ Watch: Realistic experiment results and accuracy (35:30)
The talk focused on the research methodology, feature engineering, and experimental results of the machine learning models. There was no specific live demonstration or proof-of-concept tool presented during the conference talk. The presentation detailed the process of data collection, feature extraction using Bro IDS, and the performance of various machine learning algorithms on the compiled dataset.
Defensive Implications
▶ Watch: Current limitations and future research directions (40:30)
While the research explicitly stated that the current accuracy and false positive rates are not yet suitable for real-world deployment, the findings offer several crucial defensive implications for organizations looking to enhance their security posture against HTTPS-encrypted malware:
- Metadata Matters: The most significant takeaway is that even without decrypting HTTPS traffic, valuable insights can be gleaned from network and certificate metadata. Defenders should focus on collecting and analyzing these non-payload features, as they provide an alternative avenue for detection when deep packet inspection is not feasible or desired.
- Bro (Zeek) IDS for Feature Extraction: The successful use of Bro IDS (now Zeek) highlights its utility as a foundational tool for extracting the necessary metadata. Organizations should deploy and configure Bro/Zeek to log
conn.log,ssl.log, andx509.logfor their HTTPS traffic, as these logs contain the raw data needed for such analysis. - Monitor Key Features: Security teams should prioritize monitoring the features identified as most important by this research:
- Certificate Validity Length: Look for unusually short or excessively long certificate validity periods.
- Number of Domains in Subject Alternative Names (SAN): Anomalously high or low numbers of SAN entries can be indicative of C2 or phishing campaigns.
- Certificate Validity During Capture: Analyze the "age" of a certificate relative to its total lifespan at the time of capture.
- Connection Periodicity: Unusual patterns in the timing of connections (second-level time differences) can suggest automated, malware-driven communication.
- SSL/TLS Version: Flag connections using deprecated or older SSL/TLS versions, as malware may rely on them.
- Packet and Byte Counts, Duration: Deviations from normal traffic patterns in terms of data volume and connection duration can be suspicious.
- Privacy-Preserving Alternative to TLS Inspection: For organizations with strict privacy requirements or those facing the high costs and complexity of TLS inspection, this research offers a conceptual framework for detecting malware without compromising user privacy. While the ML models need further refinement, the principle of metadata-based detection remains a powerful alternative.
- Behavioral Detection Focus: The approach shifts detection from signature-based analysis of payloads to behavioral analysis of connection patterns and certificate attributes. This makes it more resilient to polymorphic malware and zero-day threats that might not have known signatures.
- Future Research & Development: Security vendors and researchers should continue to explore and refine these metadata-based detection techniques. Integrating DNS logs (e.g., from Bro's
dns.log) to correlate domain names in certificates with actual DNS queries was suggested as a promising next step to enhance detection capabilities. - Alert Prioritization: Even with current FPRs, the identified features could be used to prioritize alerts from other security systems. If a connection flagged by an existing IDS also exhibits several anomalous metadata features, it could warrant higher investigative priority.
In conclusion, while a fully automated, low-FPR detection system is still a work in progress, this research provides a clear roadmap for defenders to proactively collect and analyze HTTPS metadata, empowering them to build more robust and privacy-respecting security controls.
Key Takeaways
- HTTPS Encryption Challenges Traditional Security: The increasing prevalence of HTTPS traffic, coupled with malware's adaptation to encrypted communications, renders traditional payload-based detection methods ineffective, creating a significant blind spot for defenders.
- Metadata Offers a Privacy-Preserving Detection Avenue: This research demonstrates that machine learning can leverage publicly available metadata from HTTPS connections and certificates (e.g., certificate validity, connection timing, domain names) to identify malicious traffic without the need for costly and privacy-compromising TLS inspection.
- Key Features for Detection Identified: Specific metadata features like certificate validity length, the number of domain names in Subject Alternative Names (SAN), connection periodicity, and SSL/TLS version are strong indicators for distinguishing between normal and malware-related HTTPS traffic.
- XGBoost Shows Promising Performance: Among the tested machine learning algorithms, XGBoost consistently delivered the best results, achieving accuracies up to 94-95% in realistic scenarios, although further refinement is needed to reduce false positive rates for practical deployment.
- Data Scarcity and FPR Remain Challenges: The research highlighted the need for more extensive and diverse data sets to improve model generalization and reduce false positive rates (which ranged from 5-10%), currently too high for production environments.
- Bro (Zeek) IDS is a Vital Tool: The use of Bro IDS (now Zeek) for extracting detailed
conn.log,ssl.log, andx509.logmetadata proved essential, underscoring its value for network security analysis and feature engineering in encrypted environments.
About the Speaker(s)
František Střasák is a researcher from the Czech Republic. At the time of this talk (BruCON 2017), he was a student at the Czech Technical University, Faculty of Engineering, where he studied Artificial Intelligence. He had recently completed his bachelor's program in June and was continuing his studies in a master's program. Beyond his academic pursuits, František enjoys music, particularly playing the drums, and has a keen interest in beers, especially looking forward to trying Belgian varieties.
František's research presented in this talk was supervised by Sebastian Garcia, a prominent researcher and lecturer at the same faculty and university. Sebastian Garcia is also the founder and head of the Stratosphere IPS project, an initiative focused on malware detection that actively supports Non-Governmental Organizations (NGOs) in their cybersecurity efforts.