|
| 1 | +--- |
| 2 | +doc_id: "DBS-COMPL-001" |
| 3 | +doc_title: "Database System - ISO/IEC 27001 Control Mapping" |
| 4 | +doc_version: "0.1.0" |
| 5 | +doc_date: "2026-04-19" |
| 6 | +doc_status: "Draft" |
| 7 | +project: "database_system" |
| 8 | +category: "COMPLIANCE" |
| 9 | +--- |
| 10 | + |
| 11 | +# ISO/IEC 27001 Control Mapping |
| 12 | + |
| 13 | +> **Scope**: This document maps the current `database_system` codebase to a curated |
| 14 | +> subset of ISO/IEC 27001:2022 Annex A controls. It records the mechanism in code and |
| 15 | +> the exact source references, and it is intentionally conservative: controls that |
| 16 | +> depend on environment configuration, operator procedures, or components outside |
| 17 | +> this repository are marked as **Out of scope** or **Partial**. |
| 18 | +> |
| 19 | +> This is **not** a certification statement. It is evidence a reviewer or adopter can |
| 20 | +> cross-check against the source tree. |
| 21 | +
|
| 22 | +**Last updated**: 2026-04-19 |
| 23 | +**Applies to**: `database_system` v1.0.0 and later, when built with `USE_OPENSSL=ON` |
| 24 | +(default since this release). |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Build-level Security Posture |
| 29 | + |
| 30 | +| Setting | Default | Where | Effect | |
| 31 | +|---------|---------|-------|--------| |
| 32 | +| `USE_OPENSSL` CMake option | `ON` | `CMakeLists.txt` | Links OpenSSL, defines `DATABASE_HAS_OPENSSL`, enables PBKDF2-HMAC-SHA256 and AES-256-GCM in `secure_connection` | |
| 33 | +| `security_credentials::encryption` | `encryption_type::tls` | `database/security/secure_connection.h` | Default transport encryption type is TLS | |
| 34 | +| `security_credentials::verify_certificate` | `true` | `database/security/secure_connection.h` | Default rejects unverified server certificates | |
| 35 | + |
| 36 | +Disabling `USE_OPENSSL` triggers a CMake `WARNING` and drops `secure_connection` to |
| 37 | +placeholder crypto — explicitly flagged as "NOT for production" in the source |
| 38 | +comment (`database/security/secure_connection.cpp`). |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## A.5 — Organisational controls |
| 43 | + |
| 44 | +### A.5.15 Access control |
| 45 | + |
| 46 | +**Mechanism**: Role-Based Access Control (RBAC) via `access_control` class. |
| 47 | +- Roles with per-table allow/deny lists and per-operation permissions. |
| 48 | +- Session lifecycle (create, validate, terminate, expire). |
| 49 | + |
| 50 | +**Source**: `database/security/secure_connection.h` (lines 193-254), |
| 51 | +`database/security/secure_connection.cpp`. |
| 52 | + |
| 53 | +**Status**: Partial. The RBAC primitives are implemented and unit-tested, but |
| 54 | +enforcement at backend boundaries depends on the consuming application wiring |
| 55 | +`access_control::check_permission` into its query path. |
| 56 | + |
| 57 | +### A.5.17 Authentication information |
| 58 | + |
| 59 | +**Mechanism**: `credential_manager` stores credentials encrypted with the master |
| 60 | +key (AES-256-GCM when built with OpenSSL). Passwords are hashed via |
| 61 | +PBKDF2-HMAC-SHA256 (100,000 iterations) — see `secure_connection.cpp` fallback |
| 62 | +comment at line 211 (`Build with OpenSSL for PBKDF2-HMAC-SHA256 support.`). |
| 63 | + |
| 64 | +**Source**: `credential_manager` in `database/security/secure_connection.h` |
| 65 | +(lines 99-127) and `.cpp`. |
| 66 | + |
| 67 | +**Status**: Covered when `USE_OPENSSL=ON`. Without OpenSSL the fallback path is |
| 68 | +not suitable for production — documented in code and flagged at CMake time. |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## A.8 — Technological controls |
| 73 | + |
| 74 | +### A.8.2 Privileged access rights |
| 75 | + |
| 76 | +**Mechanism**: Permission bitmask in `access_control::permission` distinguishes |
| 77 | +`admin` from data-plane permissions (`select`, `insert`, `update`, |
| 78 | +`delete_record`, `create`, `drop`, `alter`). |
| 79 | + |
| 80 | +**Source**: `database/security/secure_connection.h` (lines 196-205). |
| 81 | + |
| 82 | +**Status**: Partial (see A.5.15). |
| 83 | + |
| 84 | +### A.8.3 Information access restriction |
| 85 | + |
| 86 | +**Mechanism**: `access_control::check_table_access` and |
| 87 | +`query_security::validate_table_access` gate per-table access decisions. |
| 88 | + |
| 89 | +**Source**: `database/security/secure_connection.h` (lines 171, 241). |
| 90 | + |
| 91 | +**Status**: Partial. Enforcement is opt-in by the caller. |
| 92 | + |
| 93 | +### A.8.5 Secure authentication |
| 94 | + |
| 95 | +**Mechanism**: `authentication_method` enumerates `password`, `certificate`, |
| 96 | +`kerberos`, `oauth2`, `jwt`. Certificate-based and mutual-TLS are supported via |
| 97 | +`connection_security::perform_mutual_authentication` and |
| 98 | +`security_credentials::mutual_authentication`. |
| 99 | + |
| 100 | +**Source**: `database/security/secure_connection.h` (lines 35-41, 64-66, 141). |
| 101 | + |
| 102 | +**Status**: Covered (mechanism present); the actual auth provider is supplied |
| 103 | +by the consuming application or backend driver. |
| 104 | + |
| 105 | +### A.8.15 Logging |
| 106 | + |
| 107 | +**Mechanism**: `audit_logger` records database access, authentication events, |
| 108 | +and authorisation failures, with optional persistent file backing and a |
| 109 | +configurable retention window. |
| 110 | + |
| 111 | +**Source**: `database/security/secure_connection.h` (lines 268-318), |
| 112 | +`database/security/secure_connection.cpp`. |
| 113 | + |
| 114 | +**Status**: Covered for the events enumerated in `audit_logger`. Centralised |
| 115 | +log aggregation is out of scope for this repository. |
| 116 | + |
| 117 | +### A.8.16 Monitoring activities |
| 118 | + |
| 119 | +**Mechanism**: `security_monitor` performs brute-force detection, privilege- |
| 120 | +escalation monitoring, query-pattern analysis, and alert dispatch through a |
| 121 | +pluggable handler. |
| 122 | + |
| 123 | +**Source**: `database/security/secure_connection.h` (lines 332-381). |
| 124 | + |
| 125 | +**Status**: Covered at library level. Integration with a SIEM is the adopter's |
| 126 | +responsibility. |
| 127 | + |
| 128 | +### A.8.20 Network security |
| 129 | + |
| 130 | +**Mechanism**: TLS transport is the default encryption mode |
| 131 | +(`security_credentials::encryption = encryption_type::tls`). |
| 132 | +`connection_security::configure_tls` accepts CA bundle, client certificate, and |
| 133 | +client key; `set_cipher_suite` restricts allowed ciphers. |
| 134 | + |
| 135 | +**Source**: `database/security/secure_connection.h` (lines 24-29, 55, 143-145). |
| 136 | + |
| 137 | +**Status**: Covered. Cipher-suite selection and certificate management are the |
| 138 | +deployer's responsibility. |
| 139 | + |
| 140 | +### A.8.21 Security of network services |
| 141 | + |
| 142 | +**Mechanism**: `security_credentials::verify_certificate` defaults to `true`; |
| 143 | +`mutual_authentication` can be enabled to require a client certificate. |
| 144 | + |
| 145 | +**Source**: `database/security/secure_connection.h` (lines 63-66). |
| 146 | + |
| 147 | +**Status**: Covered (default-secure). |
| 148 | + |
| 149 | +### A.8.23 Web filtering |
| 150 | + |
| 151 | +**Status**: **Out of scope** — `database_system` is a database abstraction |
| 152 | +library and does not perform web filtering. |
| 153 | + |
| 154 | +### A.8.24 Use of cryptography |
| 155 | + |
| 156 | +**Mechanism**: |
| 157 | +- Password hashing: PBKDF2-HMAC-SHA256 with 100,000 iterations and a per-credential salt (OpenSSL `PKCS5_PBKDF2_HMAC`). |
| 158 | +- Symmetric encryption: AES-256-GCM (authenticated) for credential envelopes. |
| 159 | +- Random generation: OpenSSL `RAND_bytes` for salts and IVs. |
| 160 | +- Transport: TLS via the database driver (libpqxx, etc.) and/or `connection_security::configure_tls`. |
| 161 | + |
| 162 | +**Source**: `database/security/secure_connection.cpp` (guarded by |
| 163 | +`DATABASE_HAS_OPENSSL`, lines 15-21 and the comments at 206-211, 278, 331). |
| 164 | + |
| 165 | +**Status**: Covered when `USE_OPENSSL=ON` (default). Disabling OpenSSL reverts |
| 166 | +to placeholder crypto that is explicitly *not* A.8.24-compliant. |
| 167 | + |
| 168 | +### A.8.25 Secure development lifecycle |
| 169 | + |
| 170 | +**Mechanism**: |
| 171 | +- CI runs on Ubuntu (GCC/Clang), macOS, Windows (MSVC) with sanitizers |
| 172 | + (`asan`, `tsan`, `ubsan`), static analysis (`clang-tidy`, `cppcheck`), and |
| 173 | + coverage tracking. |
| 174 | +- CVE scan and SBOM generation are part of the pipeline (see |
| 175 | + `docs/contributing/CI_CD_GUIDE.md`). |
| 176 | +- Branch protection: `main` accepts only squash-merged PRs; CI must pass. |
| 177 | + |
| 178 | +**Status**: Covered at process level. See `docs/contributing/CI_CD_GUIDE.md` |
| 179 | +and `.github/workflows/` for the concrete gates. |
| 180 | + |
| 181 | +### A.8.26 Application security requirements |
| 182 | + |
| 183 | +**Mechanism**: `query_security` provides SQL-injection detection, |
| 184 | +sanitisation, parameterisation helpers (`convert_to_prepared_statement`), |
| 185 | +and table-access validation. |
| 186 | + |
| 187 | +**Source**: `database/security/secure_connection.h` (lines 160-179). |
| 188 | + |
| 189 | +**Status**: Covered for the library-level surface. Application-level input |
| 190 | +validation is still required from the caller. |
| 191 | + |
| 192 | +### A.8.28 Secure coding |
| 193 | + |
| 194 | +**Mechanism**: All public synchronous APIs return `kcenon::common::Result<T>` |
| 195 | +(no exceptions across the public ABI); clang-tidy enforces snake_case and |
| 196 | +trailing-underscore conventions; RAII is used for all owned resources. |
| 197 | + |
| 198 | +**Source**: `CLAUDE.md` "Key Patterns" section; header reviews in |
| 199 | +`database/core/` and `database/security/`. |
| 200 | + |
| 201 | +**Status**: Covered at project policy level. |
| 202 | + |
| 203 | +--- |
| 204 | + |
| 205 | +## A.5.30 / A.5.34 — Operational resilience & privacy |
| 206 | + |
| 207 | +These controls depend heavily on deployment configuration (BCP, DPIA, data |
| 208 | +residency). They are tracked at the ecosystem level (`pacs_system`, |
| 209 | +`logger_system`) and are **Out of scope** for this repository in isolation. |
| 210 | + |
| 211 | +--- |
| 212 | + |
| 213 | +## Controls explicitly out of scope |
| 214 | + |
| 215 | +| Control | Reason | |
| 216 | +|---------|--------| |
| 217 | +| A.5.7 Threat intelligence | Handled by operator, not library | |
| 218 | +| A.6 People controls | Organisational, not code | |
| 219 | +| A.7 Physical controls | Organisational, not code | |
| 220 | +| A.8.6 Capacity management | Deployment concern | |
| 221 | +| A.8.9 Configuration management | Deployment/IaC concern | |
| 222 | +| A.8.22 Segregation of networks | Deployment/network concern | |
| 223 | + |
| 224 | +--- |
| 225 | + |
| 226 | +## Change log for this document |
| 227 | + |
| 228 | +| Date | Version | Change | |
| 229 | +|------|---------|--------| |
| 230 | +| 2026-04-19 | 0.1.0 | Initial mapping, issue #569. | |
| 231 | + |
| 232 | +--- |
| 233 | + |
| 234 | +## See also |
| 235 | + |
| 236 | +- [SECURITY.md](../../SECURITY.md) — vulnerability reporting |
| 237 | +- [FEATURES_POOLING_SECURITY.md](../FEATURES_POOLING_SECURITY.md) — security feature reference |
| 238 | +- [PRODUCTION_QUALITY.md](../PRODUCTION_QUALITY.md) — production-readiness posture |
0 commit comments