kb:bestpractices:codingconventions:cybersecurity
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| kb:bestpractices:codingconventions:cybersecurity [2026/05/07 09:31] – joerg.hampel | kb:bestpractices:codingconventions:cybersecurity [2026/10/06 13:16] (current) – joerg.hampel | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | //As the EU Cyber Resilience Act (CRA) *has already entered into force in 2024, and the first legal requirements must be fulfilled starting in September 2026, we are now explicitly collecting tips, tricks, and best practices related to the topic here.// | + | <WRAP left round tip 60%> |
| - | + | **[[kb: | |
| - | Cybersecurity is part of software quality and maintainability. Secure systems should be deterministic, | + | </WRAP> |
| ===== General Principles ===== | ===== General Principles ===== | ||
| - | * Treat all external input as untrusted. | + | * Treat all external input as untrusted |
| - | * Prefer simple and explicit architectures. | + | * Prefer simple and explicit architectures |
| - | * Fail safely and log security-relevant failures. | + | * Fail safely and log security-relevant failures |
| - | * Minimize attack surface | + | * Minimize |
| - | * Apply the principle of least privilege. | + | * Keep third-party |
| + | * Apply the principle of least privilege | ||
| + | * Do not reinvent the wheel (use existing encryption algorithms etc) | ||
| + | * Review security implications during code reviews and design reviews, not only during testing | ||
| ===== Secrets and Credentials ===== | ===== Secrets and Credentials ===== | ||
| + | * Choose secure defaults | ||
| * Never hardcode: | * Never hardcode: | ||
| - | * passwords, | + | * passwords |
| - | * API keys, | + | * API keys |
| - | * certificates, | + | * certificates |
| - | * tokens, | + | * tokens |
| - | * database credentials. | + | * database credentials |
| * Do not store secrets in: | * Do not store secrets in: | ||
| - | * block diagram constants, | + | * block diagram constants |
| - | * typedef defaults, | + | * typedef defaults |
| - | * test VIs, | + | * test VIs |
| - | * screenshots, | + | * screenshots |
| - | * source-controlled config files. | + | * source-controlled config files |
| - | * Use external configuration or secure credential storage. | + | * Do not log sensitive information |
| - | * Never log sensitive information. | + | * Solutions |
| + | * " | ||
| + | * Better: Store secrets in a place the regular user cannot access | ||
| ===== Networking ===== | ===== Networking ===== | ||
| - | * Prefer encrypted communication: | + | * Prefer encrypted communication |
| - | * TLS, | + | * Avoid plaintext credentials and insecure protocols |
| - | * HTTPS, | + | * Validate remote peers (eg using certificates) |
| - | * SSH, | + | * restrict access on a network level (IP ranges etc) |
| - | * SFTP, | + | * Use existing protocols |
| - | * OPC UA security. | + | |
| - | * Avoid plaintext credentials and insecure protocols. | + | |
| - | * Validate | + | |
| * Explicitly document: | * Explicitly document: | ||
| - | * timeout behavior, | + | * timeout behavior |
| - | * reconnect strategy, | + | * reconnect strategy |
| - | * retry handling. | + | * retry handling |
| - | ===== LabVIEW-Specific Guidelines | + | ===== Databases and SQL ===== |
| + | |||
| + | * Use parameterized queries whenever possible | ||
| + | * Avoid dynamically concatenating SQL strings from user input | ||
| + | * Validate and sanitize externally provided data before database operations | ||
| + | * Restrict database permissions to the minimum required access | ||
| + | * Never store database credentials directly in source code | ||
| + | * Log database failures without exposing sensitive query data | ||
| + | * Explicitly handle connection loss and timeout behavior | ||
| + | |||
| + | |||
| + | |||
| + | ===== LabVIEW | ||
| ==== VI Server ==== | ==== VI Server ==== | ||
| - | * Disable VI Server if not required. | + | * Disable VI Server if not required |
| - | * Restrict network access and permissions. | + | * Restrict network access and permissions |
| - | * Never expose unrestricted VI Server access on production systems. | + | * Never expose unrestricted VI Server access on production systems |
| ==== Dynamic VI Loading ==== | ==== Dynamic VI Loading ==== | ||
| - | * Only load trusted plugins or VIs. | + | * Only load trusted plugins or VIs |
| - | * Avoid loading VIs from user-writable directories. | + | * Avoid loading VIs from user-writable directories |
| - | * Use strict connector pane contracts and versioning. | + | * Use strict connector pane contracts and versioning |
| - | ==== System Exec ===== | + | ==== System Exec ==== |
| - | * Treat all command line input as untrusted. | + | * Treat all command line input as untrusted |
| - | * Avoid constructing shell commands from unchecked user input. | + | * Avoid constructing shell commands from unchecked user input |
| - | * Document all external tool dependencies. | + | * Document all external tool dependencies |
| ==== File Handling ==== | ==== File Handling ==== | ||
| - | * Validate file paths and filenames. | + | * Validate file paths and filenames |
| - | * Avoid path traversal vulnerabilities. | + | * Avoid path traversal vulnerabilities |
| - | * Restrict writable and executable locations. | + | * Restrict writable and executable locations |
| ===== DQMH and Modular Architectures ===== | ===== DQMH and Modular Architectures ===== | ||
| - | * Encapsulate queues, references, and communication resources. | + | * Encapsulate queues, references, and communication resources |
| - | * Avoid exposing internal module resources. | + | * Avoid exposing internal module resources |
| - | * Validate message payloads and typedef compatibility. | + | * Validate message payloads and typedef compatibility |
| - | * Keep security-related blocking operations outside the EHL. | + | * Keep security-related blocking operations outside the EHL |
| ===== Logging and Error Handling ===== | ===== Logging and Error Handling ===== | ||
| * Log security-relevant events: | * Log security-relevant events: | ||
| - | * failed authentication, | + | * failed authentication |
| - | * rejected certificates, | + | * rejected certificates |
| - | * malformed packets, | + | * malformed packets |
| - | * permission violations. | + | * permission violations |
| * Logs should include: | * Logs should include: | ||
| - | * timestamps, | + | * timestamps |
| - | * module names, | + | * module names |
| - | * severity, | + | * severity |
| - | * connection information. | + | * connection information |
| - | * Avoid excessive logging in real-time loops. | + | * Avoid excessive logging in real-time loops |
| ===== Deployment ===== | ===== Deployment ===== | ||
| - | * Remove development tooling from production systems. | + | * Remove development tooling from production systems |
| - | * Avoid unnecessary administrator privileges. | + | * Avoid unnecessary administrator privileges |
| - | * Keep dependencies updated. | + | * Keep dependencies updated |
| - | * Prefer signed installers and executables. | + | * Prefer signed installers and executables |
| + | |||
| + | |||
| + | ===== Resources ===== | ||
| + | |||
| + | * [[kb: | ||
| - | ===== Recommended ===== | + | ---- |
| - | | + | <block 100%: |
| - | | + | A set of guidelines that recommend programming style, better practices, and methods for all our LabVIEW projects. We ask all our peers to follow these guidelines to help improve the readability of our shared source code and make software maintenance easier.</ |
| - | | + | |
| - | | + | |
| - | * Deterministic error handling | + | |
| - | * Sanitized logging | + | |
| - | * Secure communication protocols | + | |
| - | ===== Avoid ===== | + | |< 100% 50% >| |
| + | |[[kb: | ||
| - | * Hardcoded credentials | ||
| - | * Global mutable state | ||
| - | * Disabled certificate validation | ||
| - | * Unvalidated external input | ||
| - | * Arbitrary dynamic VI loading | ||
| - | * Logging secrets | ||
| - | * Silent failure handling | ||
kb/bestpractices/codingconventions/cybersecurity.1778146301.txt.gz · Last modified: 2026/05/07 09:31 by joerg.hampel