Skip to content

feat: Add AWS cloud infrastructure logs integration - #858

Open
bhaskarvilles wants to merge 45 commits into
cisagov:mainfrom
bhaskarvilles:Cloud-Infrastructure-Logs-Integration
Open

feat: Add AWS cloud infrastructure logs integration#858
bhaskarvilles wants to merge 45 commits into
cisagov:mainfrom
bhaskarvilles:Cloud-Infrastructure-Logs-Integration

Conversation

@bhaskarvilles

Copy link
Copy Markdown

Description

Adds comprehensive cloud infrastructure log ingestion and analysis capabilities to Malcolm, enabling monitoring of hybrid cloud + on-prem environments.

Related Issue

Closes #232

What's New

  • AWS VPC Flow Logs parser with security event detection
  • AWS CloudTrail parser with threat detection
  • Automated S3 log collector script
  • Comprehensive documentation with setup guides
  • Configuration templates for easy deployment

Features

✅ VPC Flow Logs parsing (v2 format)
✅ CloudTrail API activity parsing
✅ Automated S3 log collection
✅ ECS field mapping
✅ GeoIP/ASN enrichment integration
✅ Security tagging (unauthorized access, high-risk actions, etc.)

Security Event Detection

VPC Flow Logs

  • rejected_traffic - Blocked connections
  • high_volume_transfer - Large data transfers (>10MB)
  • potential_port_scan - Multiple connection rejections

CloudTrail

  • unauthorized_access_attempt - AccessDenied errors
  • high_risk_action - Destructive operations (DeleteBucket, TerminateInstances, etc.)
  • root_account_usage - Root user activity
  • failed_authentication - Failed console logins

Testing

  • Tested VPC Flow Logs parser with sample data
  • Tested CloudTrail parser with sample events
  • Verified ECS field mappings
  • Confirmed integration with Malcolm's enrichment pipeline
  • Tested with live AWS VPC Flow Logs (pending AWS account access)
  • Tested with live CloudTrail logs (pending)
  • Created dashboards (in progress)

Documentation

Files Changed

File Path Insertions
CONTRIBUTION.md 96
config/cloud-logs.env.example 25
docs/cloud-logs-integration.md 380
logstash/pipelines/enrichment/15_cloud_logs_vpc_flow.conf 130
logstash/pipelines/enrichment/16_cloud_logs_cloudtrail.conf 160
shared/bin/aws_log_collector.py 236
shared/bin/cloud-logs-requirements.txt 1

Summary

  • Files changed: 7
  • Total insertions: 961

Impact

This contribution enables Malcolm to:

  • 🌐 Monitor hybrid cloud + on-prem environments
  • 🔒 Detect cloud security threats
  • 🔗 Correlate cloud API activity with network traffic
  • 📊 Provide unified analysis platform for security teams

Checklist

  • Code follows Malcolm's style guide
  • Documentation updated
  • Commit messages are descriptive
  • ECS field mappings used consistently
  • Unit tests added (next step)
  • Dashboards created (next step)

Next Steps

  1. Create OpenSearch dashboards for VPC Flow and CloudTrail
  2. Add unit tests for parsers
  3. Test with live AWS infrastructure logs
  4. Address maintainer feedback

Author: @bhaskarvilles
Branch: Cloud-Infrastructure-Logs-Integration

mmguero and others added 30 commits June 20, 2025 20:51
- Apply multiple enhancements to `clean-processed-folder.py` so that it runs fast
enough to keep up with the generation of log files in pipeline capture mode. These
changes increased the file processing rate by a factor of 100.
  - Preprocess the filebeat registry into a format for checking file presence using the
    `in` operator.
  - Replace regular expression pattern matching for mime file types with list searching.
  - Refactor running `fuser` with the subprocess module for increased speed.
- Treat zero-length files, which have no mime type, as eligible log files.
- Update logging to improve the ability to monitor script performance.
- Fix the search for Suricata log files which was excluding log files created in the
pipeline mode.
- Run `clean-processed-folder.py` every minute in order to minimize the risk of
overflowing the partition where the log files are stored especially in the pipeline
capture mode.
Fix log files not removed quickly enough
@mmguero mmguero self-assigned this Jan 19, 2026
@mmguero mmguero added logstash Relating to Malcolm's use of Logstash cloud Relating to deployment of Malcolm in the cloud and/or with Kubernetes labels Jan 19, 2026
@mmguero mmguero added this to Malcolm Jan 19, 2026
@mmguero mmguero moved this to Review in Malcolm Jan 19, 2026
@mmguero mmguero added this to the v26.02.0 milestone Jan 19, 2026
@mmguero

mmguero commented Jan 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks, I will review this in the next week or so and get it merged for probably a February release.

- Add comprehensive unit tests for VPC Flow Logs parser (6 tests)
- Add comprehensive unit tests for CloudTrail parser (6 tests)
- Create AWS VPC Flow Logs Overview dashboard with 6 visualizations
- Create AWS CloudTrail Activity dashboard with 6 visualizations
- Add dashboard import guide with instructions

Tests cover:
- Successful parsing of log formats
- Security event detection (unauthorized access, high-risk actions)
- Protocol mapping and field extraction
- Cloud metadata validation

Dashboards include:
- Traffic/API activity timelines
- Success/failure ratios
- Top talkers/users/actions
- Protocol/security event breakdowns
- Geographic distribution maps

Related: cisagov#232
- Add AWS ELB/ALB access logs parser (Classic ELB and ALB support)
- Add AWS S3 access logs parser with sensitive file detection
- Add AWS Route 53 query logs parser with DNS tunneling/DGA detection
- Add Azure NSG Flow Logs parser with port scan detection
- Add Azure Activity Logs parser with high-risk operation monitoring

All parsers include:
- ECS field mapping
- Security event detection and tagging
- Integration with Malcolm's GeoIP/ASN enrichment
- Comprehensive threat detection (SQL injection, DGA, tunneling, etc.)

Updated log collector to support all new log types.

Related: cisagov#232
@mmguero

mmguero commented Jan 21, 2026

Copy link
Copy Markdown
Collaborator

Just wanted to let you know I saw your updates. It will probably be next week sometime before I'm able to carve out the time to review this, but know it's appreciated and we'll get them reviewed. I may end up moving the logstash filters to a separate (new) parse pipeline rather than putting them in "enrichment" but don't worry about it for now, that's easy to adjust. Cheers.

@bhaskarvilles

Copy link
Copy Markdown
Author

@mmguero Thanks for your reply, Just adding more enhancements, i will wait for your review and for the next release, planning to integrate Azure, Akamai and other cloud provider logs as well.

Parsers:
- AWS RDS: error, slow query (DDL/DML/SELECT classify), audit, PostgreSQL
- Azure App Gateway: access logs + WAF (OWASP rule group detection)

Dashboards (7 new):
- aws-elb-overview: requests, status codes, response time, top clients, SQLi events
- aws-s3-access-overview: ops over time, bytes, sensitive file/security events
- aws-route53-overview: queries, response codes, DNS threat events (tunneling/DGA)
- azure-nsg-overview: traffic timeline, allow/deny, protocols, port scans
- azure-activity-overview: operations, outcomes, top users, high-risk events
- azure-appgw-overview: (via cloud-unified) WAF blocks, OWASP rules
- cloud-unified-security: unified cross-provider overview with geo attack map

Alerting Rules (10 monitors):
- Mass unauthorized access attempts
- DNS tunneling / DGA
- S3 sensitive file access
- SQL injection (ELB + AppGW WAF)
- Azure high-risk resource deletion
- CloudTrail root account usage
- Azure WAF RCE/LFI attack
- RDS mass authentication failures
- Large data exfiltration (>1GB)
- Azure NSG mass port scanning

Related: cisagov#232
@mmguero

mmguero commented Feb 23, 2026

Copy link
Copy Markdown
Collaborator

I'm on site at one of our funding sources this week, but I plan on looking at this and getting it merged next week. Thanks for your patience!

@mmguero mmguero removed their assignment Mar 11, 2026
@mmguero mmguero modified the milestones: v26.03.0, v26.04.0 Mar 16, 2026
@mmguero

mmguero commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

I've got a number of concerns/questions about this PR.

  • Configuration environment variables not used by Malcolm, or anywhere that I can see:
    • You've created this config .env file, but I don't see anywhere these variables are actually used or referenced other than in cloud-logs-integration.md. .env files in ./config/ are usually intended to be used internally by Malcolm containers.
$ cat config/cloud-logs.env.example |rg -o "\w+=" | tr -d '=' | tr '\n' '|' | sed "s/|$//" | x rg
config/cloud-logs.env.example
2:AWS_REGION=us-east-1
3:AWS_VPC_FLOW_LOGS_BUCKET=
4:AWS_VPC_FLOW_LOGS_PREFIX=AWSLogs/
5:AWS_CLOUDTRAIL_BUCKET=
6:AWS_CLOUDTRAIL_PREFIX=AWSLogs/
7:AWS_LOG_COLLECTION_ENABLED=false
8:AWS_LOG_COLLECTION_INTERVAL=300
11:AZURE_SUBSCRIPTION_ID=
12:AZURE_NSG_FLOW_LOGS_CONTAINER=
13:AZURE_LOG_COLLECTION_ENABLED=false
14:AZURE_LOG_COLLECTION_INTERVAL=300
17:CLOUD_LOGS_OUTPUT_DIR=/var/log/malcolm/cloud-logs
18:CLOUD_LOGS_RETENTION_DAYS=90
19:CLOUD_LOGS_CLEANUP_ENABLED=true
22:CLOUD_LOGS_MAX_FILES_PER_RUN=100
25:CLOUD_LOGS_INDEX_PREFIX=malcolm-cloud

docs/cloud-logs-integration.md
114:AWS_REGION=us-east-1
115:AWS_VPC_FLOW_LOGS_BUCKET=my-vpc-flow-logs
116:AWS_VPC_FLOW_LOGS_PREFIX=AWSLogs/123456789012/vpcflowlogs/
117:AWS_LOG_COLLECTION_ENABLED=true
118:AWS_LOG_COLLECTION_INTERVAL=300
121:CLOUD_LOGS_OUTPUT_DIR=/var/log/malcolm/cloud-logs
122:CLOUD_LOGS_RETENTION_DAYS=90
  • Dashboards included are not compatible with how Malcolm initializes dashboards on startup:

    • The ./dashboards/dashboards/*.ndjson files you've added won't be automatically created/imported into Malcolm. For dashboards to be automatically created on startup and set up correctly with the index patterns, they need to be exported using the Malcolm dashboard export API. That endpoint ensures that the exported dashboard file has the replacers automatically put in it that, when re-imported, will be used to substitute in custom user index pattern settings that are found in ./config/opensearch.env.
  • Your cloud-logs-integration.md talks about this data pipeline, but I don't see where any of it really plugs into Malcolm.

    • For example, it talks about this /var/log/malcolm/cloud-logs directory, which is stored in CLOUD_LOGS_OUTPUT_DIR, but that environment variable isn't used. When you pass it into aws_log_collector.py with --output-dir, then you talk about "Check Filebeat is monitoring the directory" but I don't see anywhere about filebeat actually being configured to it. And where would that even happen? This scripts is being run outside outside of the Malcolm containers, and so I assume you're talking about some user-managed external filebeat where those are watched?
    • We don't really have any existing code that does that sort of thing, like an external script that creates log files and then (if this is your intent) the log files are mounted into the Malcolm containers. I'd probably be more inclined to have your script send logs to Malcolm's JSON-over-TCP/TLS listener (configuration, "Expose Malcolm Service Ports", "Expose Filebeat TCP", etc.) and then route those to an entirely separate Logstash pipeline (pre-enrichment pipeline) rather than putting all of your logstash conf files in the enrichment pipeline.

Frankly, and no offense intended, my initial look at this makes me feel a lot of this is pretty heavily vibe-coded.

@mmguero mmguero modified the milestones: v26.04.2, z.staging Apr 27, 2026
@mmguero
mmguero force-pushed the main branch 2 times, most recently from fb19199 to 0b3b9ef Compare May 20, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cloud Relating to deployment of Malcolm in the cloud and/or with Kubernetes logstash Relating to Malcolm's use of Logstash

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

3 participants