maec-rs
Production-ready Rust implementation of MAEC 5.0 (Malware Attribute Enumeration and Characterization)
maec-rs provides a complete, type-safe implementation of the MAEC 5.0 specification for representing and sharing structured malware analysis data. Built for threat intelligence platforms, malware analysis tools, and security orchestration systems.
✨ Features
Complete MAEC 5.0 Support
- ✅ All Core Objects - Package, MalwareFamily, MalwareInstance, Behavior, Capability, etc.
- ✅ All Open Vocabularies - Type-safe enums for labels, delivery vectors, capabilities, etc.
- ✅ JSON & XML Serialization - Dual format support via serde
- ✅ Builder Pattern - Ergonomic object construction with validation
- ✅ Type-Safe IDs - Automatic ID generation and validation
- ✅ STIX Integration - Reference STIX Cyber Observable Objects
Production-Ready
- 🔍 Comprehensive Error Handling - thiserror-based errors with context
- ✅ Full Validation - Required fields, ID formats, schema compliance
- 📡 MIME Type Constants - Standard HTTP/TAXII content types
- 🧪 Well-Tested - 30+ unit and integration tests
- 📚 Fully Documented - Rustdoc with examples for all public APIs
- ⚡ Zero Unsafe Code - Memory-safe and thread-safe
Rust Quality
- Type-safe with no runtime overhead
- Efficient serialization/deserialization
- Follows Rust API guidelines
- Clippy-clean with no warnings
📦 Installation
Add to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["derive"] }
= "1.0"
= "0.4"
🚀 Quick Start
Creating MAEC Objects
use ;
use Utc;
Working with Packages
use ;
// Load a package from JSON
let json_data = read_to_string?;
let package: Package = from_str?;
// Validate the package
package.validate?;
// Query malware families
for family in package.malware_families
// Query behaviors
for behavior in package.behaviors
// Access malware instances
for instance in package.malware_instances
Creating Malware Instances
use ;
let instance = builder
.add_instance_object_ref
.name
.add_label
.description
.field_data
.build?;
println!;
ATT&CK Integration
use ;
let behavior = builder
.name
.description
.add_technique_ref
.build?;
Using Vocabularies
use ;
use Utc;
// Type-safe malware labels
let family = builder
.name
.add_label
.add_label
.field_data
.build?;
// Supported processor architectures
let architectures = vec!;
📖 Core Concepts
MAEC Objects
Package - Top-level container for all MAEC data
let package = builder
.schema_version
.add_malware_family
.build?;
MalwareFamily - Related malware instances with common lineage
let family = builder
.name
.add_label
.add_label
.build?;
MalwareInstance - Individual malware sample
let instance = builder
.add_instance_object_ref
.name
.build?;
Behavior - Specific purpose of malware code (e.g., keylogging)
use BehaviorVocab;
let behavior = builder
.name
.description
.build?;
Capability - High-level malware capability (e.g., credential theft)
let capability = new;
MAEC Vocabularies
Type-Safe Enumerations for all MAEC open vocabularies:
MalwareLabel- ransomware, trojan, keylogger, rootkit, etc. (34 types)DeliveryVector- email-attachment, phishing, exploit-kit, etc. (17 vectors)ProcessorArchitecture- x86, x86-64, arm, mips, etc. (8 architectures)CapabilityVocab- anti-detection, data-theft, persistence, etc. (19 capabilities)AnalysisConclusionType- benign, malicious, suspicious, indeterminateAnalysisType- static, dynamic, combinationConfidenceMeasure- low, medium, high, none, unknownObfuscationMethod- packing, code-encryption, string-obfuscation, etc.CommonAttribute- Platform, protocol, vulnerability references, etc.MalwareConfigurationParameter- C2 addresses, mutex names, etc.OsFeature- Registry keys, services, hooks, WMI, etc.EntityAssociation- Relationship types between MAEC entities
Helper Types
Name - Malware name with optional source and confidence
let name = with_source;
FieldData - Temporal data and delivery vectors
let field_data = builder
.first_seen
.add_delivery_vector
.build?;
Relationship - Links between MAEC objects
let rel = new;
🌐 STIX Integration
MAEC complements STIX by providing detailed malware analysis. Reference STIX Cyber Observable Objects:
use HashMap;
let mut observables = new;
observables.insert;
let package = builder
.observable_objects
.build?;
🔧 CLI Tool
The maec CLI provides format conversion and validation:
# Convert JSON to pretty JSON
# Convert JSON to XML (limited support)
# Generate JSON Schema
📚 Examples
See the examples/ directory:
basic.rs- Creating and serializing MAEC packages- More examples coming soon!
Run examples:
🧪 Testing
# Run all tests
# Run with output
# Run specific test
# Check formatting
# Run clippy
Test Coverage: 26+ tests passing (23 unit + 3 integration + vocabulary tests)
📐 Architecture
maec-rs/
├── src/
│ ├── lib.rs # Public API & re-exports
│ ├── common/ # CommonProperties, MaecObject trait, helpers
│ ├── error.rs # MaecError types with thiserror
│ ├── objects/ # MAEC object implementations
│ │ ├── package.rs # Package with builder
│ │ ├── malware_family.rs
│ │ ├── malware_instance.rs
│ │ ├── behavior.rs
│ │ ├── capability.rs
│ │ ├── types.rs # Name, FieldData
│ │ └── ...
│ └── bin/maec.rs # CLI tool
├── schemas/ # MAEC 5.0 JSON schemas (reference)
├── tests/ # Integration tests
└── examples/ # Usage examples
🔗 Companion Projects
Part of the Threatwise threat intelligence ecosystem:
- stix-rs - STIX 2.1 implementation (complete, production-ready)
- taxii-rs - TAXII 2.1 server/client
- maec-rs - You are here!
📝 Roadmap
Completed ✅
- Core MAEC 5.0 objects (Package, MalwareFamily, MalwareInstance, Behavior, Capability)
- All MAEC 5.0 open vocabularies (12+ vocabulary enumerations)
- Builder pattern for all objects
- JSON serialization/deserialization
- JSON Schema generation
- Comprehensive error handling with thiserror
- ID generation and validation (UUID-based)
- CLI tool (to-json, to-xml, schema)
- Full documentation with examples
- 100% MAEC 5.0 Specification Compliance
Future Enhancements 🚧
- Additional object types (DynamicFeatures, StaticFeatures, AnalysisMetadata)
- Behavior vocabulary enum (190+ behaviors - currently use strings)
- MalwareAction vocabulary enum (210+ actions - currently use strings)
- Operating System vocabulary enum (110+ OS versions)
- Enhanced STIX integration helpers
- More examples and tutorials
Future 🔮
- Query helpers and filtering APIs
- Validation against MAEC JSON schemas
- Bundle merging and deduplication
- Performance optimizations with rkyv
🤝 Contributing
Contributions welcome! This project follows Rust API guidelines and maintains high code quality standards.
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run
cargo fmt && cargo clippy && cargo test - Submit a pull request
📄 License
This project is licensed under either of:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.
🙏 Acknowledgments
- OASIS CTI Technical Committee - MAEC specification
- MITRE Corporation - MAEC project leadership
📞 Support
- Issues: GitHub Issues
- Documentation: docs.rs/maec-rs
- MAEC Specification: MAEC 5.0 Docs