4.2 KiB
RustScan Production Fix - Handoff Document
Date: June 8, 2025
Issue: RustScan executable not found in production sirius-engine container
Status: ✅ RESOLVED
🚨 Problem Summary
The sirius-engine container in production was failing discovery scans with the error:
Discovery failed for 192.168.123.10: discovery scan failed for 192.168.123.10: Failed to start command: exec: "rustscan": executable file not found in $PATH
🔍 Root Cause Analysis
The issue was in the multi-stage Dockerfile for sirius-engine (sirius-engine/Dockerfile):
- RustScan Installation: RustScan was installed to
/root/.cargo/bin/(root user's directory) - User Switch: Container switched to
USER siriusfor security - PATH Mismatch: PATH still pointed to
/root/.cargo/binwhich thesiriususer couldn't access
Key Problem Code
# Install Rust and RustScan
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \
. ~/.cargo/env && \
cargo install --git https://github.com/RustScan/RustScan.git --branch master
ENV PATH="/root/.cargo/bin:${PATH}"
# ... later in the file ...
USER sirius # Can't access /root/.cargo/bin anymore!
🔧 Solution Implemented
Modified the Dockerfile to install RustScan in a system-wide location accessible to all users:
Changes Made
- Development Stage Fix (lines 87-93):
# Install Rust and RustScan to /usr/local/bin for system-wide access
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \
. ~/.cargo/env && \
cargo install --git https://github.com/RustScan/RustScan.git --branch master && \
cp ~/.cargo/bin/rustscan /usr/local/bin/ && \
chmod +x /usr/local/bin/rustscan
ENV PATH="/usr/local/bin:${PATH}"
- Production Runtime Stage Fix (lines 170-176):
# Install Rust and RustScan to /usr/local/bin for system-wide access
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \
. ~/.cargo/env && \
cargo install --git https://github.com/RustScan/RustScan.git --branch master && \
cp ~/.cargo/bin/rustscan /usr/local/bin/ && \
chmod +x /usr/local/bin/rustscan
ENV PATH="/usr/local/bin:${PATH}"
- Final PATH Fix (line 245):
# Set environment variables
ENV GO_ENV=production
ENV PATH="/usr/local/bin:${PATH}" # Changed from /root/.cargo/bin
✅ Verification Results
After rebuilding and testing:
# ✅ RustScan is accessible
$ docker exec sirius-engine which rustscan
/usr/local/bin/rustscan
# ✅ RustScan is functional
$ docker exec sirius-engine rustscan --version
rustscan 2.4.1
# ✅ Engine services running properly
$ docker logs sirius-engine --tail 5
Services started successfully. Monitoring...
🎯 Impact
- Discovery Scans: Now functional in production
- Port Scanning: RustScan available for fast port discovery
- Security: Maintains non-root execution with
siriususer - Performance: No performance impact, same RustScan version (2.4.1)
🔄 Deployment Process
To apply this fix:
-
Rebuild Engine:
docker compose -f docker-compose.yaml -f docker-compose.production.yaml up sirius-engine -d --build -
Verify Installation:
docker exec sirius-engine which rustscan docker exec sirius-engine rustscan --version -
Test Scanning: Run a discovery scan to verify functionality
📋 Files Modified
sirius-engine/Dockerfile- Fixed RustScan installation and PATH configuration
🔧 Technical Details
Build Process
- Build Time: ~90 seconds (includes Rust compilation)
- Image Size: No significant change
- Dependencies: Same (Ubuntu 22.04 base with Rust toolchain)
Security Considerations
- ✅ Maintains non-root execution
- ✅ RustScan accessible to service user
- ✅ No privileged permissions required
🚀 Next Steps
- Monitor production scanning performance
- Consider caching compiled RustScan binary for faster builds
- Update development documentation with new container behavior
Resolution Status: ✅ Complete
Production Ready: ✅ Yes
Testing Required: Basic discovery scan verification
Note: This fix resolves the immediate production issue. All scanning functionality should now work correctly in production environments.