|
| 1 | +# Devcontainer Security Hardening |
| 2 | + |
| 3 | +This directory contains security-hardened devcontainer configurations for the GitHub Docs project. These configurations follow security best practices to minimize potential attack vectors while maintaining development functionality. |
| 4 | + |
| 5 | +## Available Configurations |
| 6 | + |
| 7 | +### 1. Default Configuration (`devcontainer.json`) |
| 8 | +- **Security Level**: Moderate |
| 9 | +- **Use Case**: Standard development with basic security hardening |
| 10 | +- **Key Security Features**: |
| 11 | + - Removed SSH daemon access |
| 12 | + - Pinned GitHub CLI version |
| 13 | + - Disabled automatic git fetching |
| 14 | + - Removed external repository permissions |
| 15 | + - Disabled automatic server startup |
| 16 | + - Commented out automatic port visibility |
| 17 | + |
| 18 | +### 2. Hardened Configuration (`devcontainer.hardened.json`) |
| 19 | +- **Security Level**: High |
| 20 | +- **Use Case**: Security-focused development with minimal features |
| 21 | +- **Key Security Features**: |
| 22 | + - Minimal extension set |
| 23 | + - No automatic command execution |
| 24 | + - Manual dependency installation required |
| 25 | + - Reduced resource allocation |
| 26 | + - Explicit security-focused naming |
| 27 | + |
| 28 | +### 3. Team A Secure Configuration (`team-a-secure/devcontainer.json`) |
| 29 | +- **Security Level**: High |
| 30 | +- **Use Case**: Team-specific secure configuration |
| 31 | +- **Key Security Features**: |
| 32 | + - Team-specific extension subset |
| 33 | + - Manual setup required |
| 34 | + - Reduced resource requirements |
| 35 | + |
| 36 | +### 4. Team B Secure Configuration (`team-b-secure/devcontainer.json`) |
| 37 | +- **Security Level**: Maximum |
| 38 | +- **Use Case**: Ultra-secure development environment |
| 39 | +- **Key Security Features**: |
| 40 | + - Minimal extension set (only essential linting) |
| 41 | + - No automatic commands whatsoever |
| 42 | + - Workspace trust required |
| 43 | + - Git sync confirmation required |
| 44 | + - Minimal resource allocation |
| 45 | + |
| 46 | +## Security Improvements |
| 47 | + |
| 48 | +### Removed Security Risks |
| 49 | +1. **SSH Daemon**: Removed `"sshd": "latest"` feature that provided remote access |
| 50 | +2. **External Repository Access**: Removed automatic permissions for `github/docs-early-access` |
| 51 | +3. **Automatic Command Execution**: Minimized or removed automatic lifecycle commands |
| 52 | +4. **Unpinned Versions**: Changed `"latest"` to specific pinned versions |
| 53 | +5. **Auto-fetching**: Disabled automatic git fetch operations |
| 54 | + |
| 55 | +### Enhanced Security Features |
| 56 | +1. **Version Pinning**: All features use specific versions instead of "latest" |
| 57 | +2. **Minimal Extensions**: Reduced extension sets to only essential tools |
| 58 | +3. **Manual Operations**: Require manual approval for sensitive operations |
| 59 | +4. **Resource Limits**: Reduced resource allocation where appropriate |
| 60 | +5. **Non-root User**: Maintained non-root user execution |
| 61 | + |
| 62 | +## Usage |
| 63 | + |
| 64 | +### Selecting a Configuration |
| 65 | +When creating a codespace, you can choose from the available configurations: |
| 66 | +- Default project configuration (moderately hardened) |
| 67 | +- Team A codespace config (highly secure) |
| 68 | +- Team B codespace config (maximum security) |
| 69 | + |
| 70 | +### Manual Setup Requirements |
| 71 | +For security-hardened configurations: |
| 72 | +1. Install dependencies: `npm ci` |
| 73 | +2. Start the development server: `npm start` |
| 74 | +3. Configure port visibility manually if needed: `gh cs ports visibility 4000:public` |
| 75 | + |
| 76 | +## Security Best Practices |
| 77 | + |
| 78 | +1. **Review Configuration**: Always review devcontainer configurations before use |
| 79 | +2. **Minimal Permissions**: Only grant necessary permissions and features |
| 80 | +3. **Manual Operations**: Prefer manual over automatic operations for sensitive tasks |
| 81 | +4. **Version Pinning**: Use specific versions instead of "latest" tags |
| 82 | +5. **Regular Updates**: Keep pinned versions updated but test changes thoroughly |
| 83 | + |
| 84 | +## Migration Guide |
| 85 | + |
| 86 | +### From Standard to Hardened Configuration |
| 87 | +1. Switch to `devcontainer.hardened.json` or team-specific configuration |
| 88 | +2. Install dependencies manually: `npm ci` |
| 89 | +3. Start development server manually: `npm start` |
| 90 | +4. Configure port visibility if needed: `gh cs ports visibility 4000:public` |
| 91 | + |
| 92 | +### Custom Team Configurations |
| 93 | +To create a custom secure configuration: |
| 94 | +1. Copy an existing team configuration |
| 95 | +2. Customize extensions and settings for your team's needs |
| 96 | +3. Follow the minimal permissions principle |
| 97 | +4. Test the configuration thoroughly |
| 98 | + |
| 99 | +## Security Considerations |
| 100 | + |
| 101 | +- These configurations prioritize security over convenience |
| 102 | +- Some automatic features have been disabled and require manual intervention |
| 103 | +- External repository access must be granted explicitly when needed |
| 104 | +- Review and approve all configuration changes through your security review process |
0 commit comments