章节主线
Software Development Security.
软件开发安全。
本章关注如何在开发活动里提前设计安全,而不是上线后靠运维补救。
Domain 8 是 CISSP 软件安全核心领域。
左侧是英文原文摘录、中文直译、小白解释和考点提醒;右侧是对应画报。手机端会先显示画报,点击图片可放大查看。
第 20 章把安全嵌入软件开发生命周期。安全不是上线前补丁,而是从需求、设计、编码、测试、部署到维护全过程都要持续考虑。
Software Development Security.
软件开发安全。
本章关注如何在开发活动里提前设计安全,而不是上线后靠运维补救。
Domain 8 是 CISSP 软件安全核心领域。
Security should be a consideration at every stage.
安全应在每个阶段被考虑。
需求、设计、编码、测试、部署、维护都要有安全活动。
Early security involvement 是正确方向。
It is easier to address issues early.
越早处理问题越容易。
需求阶段修一个安全设计问题,比生产环境修漏洞成本低得多。
Shift-left security 的考试直觉。
Integrate security into the development life cycle.
将安全集成到开发生命周期。
开发过程要有组织、有方法、有审查,而不是自由发挥。
Formalized SDLC supports secure systems。
Controls apply to software development ecosystems.
控制适用于软件开发生态系统。
语言、库、IDE、运行时、CI/CD、仓库、API 都可能带来风险。
考试会从生态组件角度问风险。
Assess the security impact of acquired software.
评估采购软件的安全影响。
不是自己写的软件也要做风险评估、配置和测试。
COTS、OSS、SaaS 都不能免评估。
Auditing and logging of changes.
对变更进行审计和日志记录。
代码和配置变更必须可追踪,便于调查和回滚。
Change logging mitigates risk。
Define secure coding guidelines and standards.
定义安全编码指南和标准。
输入验证、错误处理、API 安全、失败安全都是本章重点。
Secure coding 不只是程序员细节,也是治理要求。
软件不是孤立代码。编程语言、共享库、IDE、插件和运行时环境都会影响安全,尤其是第三方库漏洞和 API Key 泄露等供应链风险。
Developers use programming languages.
开发人员使用编程语言。
机器语言、汇编、高级语言、解释型语言和编译型语言都有不同安全取舍。
Compiled vs interpreted code 的优缺点要会。
Compiled code hides source instructions.
编译代码隐藏源指令。
最终用户不容易看到源码,但恶意逻辑也可能藏在不可见代码里。
Compiled code may hide flaws from end users。
Interpreted code exposes source code.
解释型代码暴露源代码。
用户可查看源代码,但接触软件的人也可能修改它。
Interpreted code has visibility and tampering tradeoffs。
Some languages rely on runtime environments.
某些语言依赖运行时环境。
JVM、.NET、Node 等运行时要保持补丁、权限和配置安全。
Runtime vulnerability affects applications using it。
Libraries contain reusable code.
库包含可复用代码。
库能提高效率,但库漏洞会被许多应用继承。
Heartbleed/OpenSSL 是共享库风险经典例子。
Know the origins of shared code.
了解共享代码来源。
要追踪库来源、版本、许可证、维护状态和安全公告。
Software composition awareness 是供应链安全基础。
IDEs provide a single development environment.
IDE 提供统一开发环境。
IDE 插件、调试器、编译器和配置也可能影响安全。
Tool set security matters。
Tool sets reduce program change errors.
工具集可减少程序变更错误。
标准化工具链能降低人为错误,但自身也要受控。
工具链属于 development ecosystem。
安全编码的基础是不要相信输入,妥善管理会话,避免错误信息泄露敏感细节,并在失败时进入安全状态。
Input validation checks user input.
输入验证检查用户输入。
检查类型、长度、范围、格式和允许字符,防止异常输入破坏系统。
Input validation 是防注入和 XSS 的基础。
Encode characters with alternative code.
用替代编码处理字符。
浏览器显示相同内容,但不会把危险字符当代码执行。
Encoding helps prevent script execution。
Browser-side code is subject to manipulation.
浏览器端代码可能被用户篡改。
不能只靠前端验证,后端也必须验证。
Never trust client-side validation alone。
Sessions should be securely tracked.
会话应被安全跟踪。
令牌、Cookie、超时、加密通道和重新认证都要考虑。
Session management transmitted over encrypted channels。
Integrate with existing authentication systems.
集成现有认证系统。
自己造认证库容易出错,优先用成熟、受控的身份系统。
Use established authentication systems/libraries。
Error information helps debugging.
错误信息有助于调试。
内部日志可以详细,给用户的错误不能泄露表结构、路径和堆栈。
Verbose errors leak information to attackers。
Log tampering and administrative events.
记录篡改和管理事件。
状态变化、管理功能、安全配置修改都应写入集中日志。
Application logging supports incident response。
Fail-secure puts the system into high security.
失败安全使系统进入高安全状态。
发生不可预测故障时,默认拒绝或关闭风险功能。
Most security environments prefer fail-secure。
正式 SDLC 把开发活动拆成阶段,每个阶段都有安全输入和交付物。安全需求和控制规范要从早期设计开始,而不是最后测试才补。
Development processes share common activities.
开发过程有共同活动。
虽然模型不同,但需求、设计、控制、编码、测试、部署、维护都常见。
理解原则比死背模型名称更重要。
Create basic security objectives.
创建基本安全目标。
在概念阶段先明确系统要保护什么、为什么要保护。
Early planning includes security objectives。
Develop a functional requirements document.
形成函数/功能需求文档。
把用户需求转换成开发人员可实现的规格。
Functional requirements drive later design。
Controls are designed from earliest stages.
控制从最早阶段开始设计。
根据风险分析定义身份、访问、日志、输入验证、加密等安全控制。
Control specifications should be revisited after major design changes。
Stakeholders approve the software design.
利益相关方批准软件设计。
设计需要满足业务、用户、安全和运维目标。
Stakeholder blessing precedes coding。
Schedule code review walk-throughs.
安排代码审查走查。
开发人员逐模块审查代码,发现缺陷和不符合规范之处。
Code review supports quality and security。
UAT verifies user requirements.
UAT 验证用户需求。
测试既包括功能测试,也包括安全测试。
Security testing should be part of testing phase。
Changes require formal change management.
变更需要正式变更管理。
上线后仍要补丁、修 Bug、加功能,但不能绕过流程。
Maintenance and change management are SDLC activities。
不同开发模型对阶段、反馈、风险和交付节奏的处理不同。CISSP 常考瀑布的顺序性、螺旋的风险和原型、敏捷的变化响应以及 SAFe 的规模化敏捷。
Choose an SDLC model appropriate for the environment.
选择适合环境的 SDLC 模型。
安全人员不一定决定模型,但要理解模型如何影响安全控制。
Management approval is an initial SDLC step。
Waterfall uses sequential activities.
瀑布使用顺序活动。
阶段依次向前推进,传统模型强调计划和阶段性完成。
Waterfall = sequential seven-stage approach。
Return to previous phase to correct defects.
可回到上一阶段纠正缺陷。
发现错误时通常只允许有限回退。
瀑布不擅长快速变化需求。
Each loop develops a prototype.
每个循环开发一个原型。
反复风险分析、原型、评估,逐步逼近最终系统。
Spiral = iterative risk-driven prototypes。
Working software over comprehensive documentation.
可工作的软件胜过详尽文档。
敏捷更重视客户协作、变化响应和频繁交付。
Agile 是 philosophy,不是单一方法。
Scrum, Kanban, Lean, RAD, and others.
Scrum、Kanban、Lean、RAD 等。
这些是实现敏捷哲学的具体框架或方法。
Scrum 常考每日会议和 backlog。
SAFe scales Agile across multiple teams.
SAFe 把敏捷扩展到多个团队。
大型组织用它协调多个敏捷团队、发布列车和组合层目标。
SAFe = Scaled Agile Framework。
Security requirements must fit the model.
安全需求必须适配模型。
瀑布可在阶段门控加入安全,敏捷/DevOps 要把安全自动化进迭代。
模型不同,安全活动方式不同。
成熟度模型帮助组织从混乱、临时的开发过程,逐步走向可重复、可定义、可度量、持续改进的过程。SAMM 专门关注软件保障成熟度。
Improve maturity and quality of software processes.
改进软件过程成熟度和质量。
软件质量很大程度取决于开发过程质量。
Maturity model = evolutionary improvement path。
Initial phase has ad hoc processes.
初始阶段流程临时混乱。
成功依赖个人英雄,而不是稳定流程。
SW-CMM Level 1 = Initial。
Initial, Repeatable, Defined, Managed, Optimizing.
初始、可重复、已定义、已管理、优化。
级别越高,过程越标准、可测量、可持续改进。
CMMI Level 4 常叫 Quantitatively Managed。
CMMI focuses on process integration.
CMMI 关注过程集成。
CMM 更偏孤立过程,CMMI 更强调整合。
CMM largely superseded by CMMI。
SAMM helps assess software assurance maturity.
SAMM 帮助评估软件保障成熟度。
它把安全活动放进开发和维护过程。
SAMM 是 open-source project。
Governance, Design, Implementation, Verification, Operations.
治理、设计、实现、验证、运营。
每个功能下都有安全实践,如威胁评估、安全构建和安全测试。
SAMM business functions 要会识别。
IDEAL has five phases.
IDEAL 有五个阶段。
Initiating、Diagnosing、Establishing、Acting、Learning。
IDEAL 常和 SW-CMM 记忆表一起出现。
Gantt and PERT support scheduling.
Gantt 和 PERT 支持项目调度。
Gantt 看时间和任务,PERT 看估算和依赖。
PERT relates estimates and standard deviation。
发布后的软件仍会持续变化。变更管理控制请求、修改和发布;软件配置管理控制版本和配置;DevOps/DevSecOps 则要求安全跟上快速交付节奏。
Changes should be logged centrally.
变更应集中记录。
集中变更记录支持审计、调查、排错和分析。
Central repository supports future auditing。
Request control organizes modification requests.
请求控制组织修改请求。
用户提出需求,管理者做成本收益,开发者排优先级。
Request control = request framework and prioritization。
Change control recreates and analyzes issues.
变更控制复现并分析问题。
开发人员设计和测试修复方案,避免直接改生产。
Change control includes quality restrictions and documentation。
Release control approves production release.
发布控制批准生产发布。
发布前要移除调试代码和后门,并做验收测试。
Release control ensures only approved changes reach production。
Configuration identification documents products.
配置识别记录软件产品配置。
知道组织里有哪些版本、组件和配置。
SCM has four main components。
Configuration control manages version changes.
配置控制管理版本变化。
只能从授权发行版按政策更新。
Unauthorized distributions should not be used。
Status accounting tracks authorized changes.
状态核算跟踪授权变更。
记录所有批准的配置变化。
Formalized procedures track changes。
Configuration audits compare production and records.
配置审计比较生产环境和记录。
确认实际环境与台账一致,没有未授权配置变化。
Configuration audit detects drift。
DevOps 把开发、质量和运维整合,DevSecOps 把安全也放进同一条流水线。快速交付需要自动化安全测试、API 保护和职责分离。
DevOps combines development and operations.
DevOps 结合开发和运维。
目标是减少团队隔阂,加快开发、测试和部署。
DevOps includes development, QA, and operations。
Code may roll out many times per day.
代码可能每天发布多次。
持续集成/持续交付依赖高度自动化。
CI/CD requires automation and controls。
Security must move with the same agility.
安全必须以同样敏捷速度前进。
把安全扫描、策略和审查嵌入流水线,而不是另起炉灶。
DevSecOps = development + security + operations。
Security controls are managed by code.
安全控制由代码管理。
策略、基础设施和安全控制可直接集成到 CI/CD。
Software-defined security supports DevSecOps。
APIs allow direct service interaction.
API 允许直接与服务交互。
绕过传统页面,直接调用底层功能。
API security requires per-call authentication and authorization。
API keys are like passwords.
API Key 像密码。
应安全存储、加密传输、避免进入代码仓库。
泄露 API key 可导致云资源被滥用。
Design tests as modules are designed.
模块设计时就设计测试。
测试数据和路径应尽可能覆盖正常、异常、边界和滥用场景。
Use cases + misuse cases。
White-box, black-box, and gray-box testing.
白盒、黑盒和灰盒测试。
白盒有源码,黑盒从用户视角,灰盒两者结合但不逐行分析内部。
White-box = source code access。
代码仓库是协作中心,也是泄露、篡改和供应链风险点。商业软件、开源软件和 SaaS 都要做安全评估、配置审查和供应商管理。
Repositories store source code centrally.
仓库集中存储源代码。
GitHub、Bitbucket、SourceForge 等还提供版本控制、Bug 跟踪和发布管理。
Repository broader than library。
Control read and write access.
控制读写访问。
读权限泄露敏感代码,写权限可导致代码被篡改。
Least privilege applies to repositories。
Do not include API keys in public repositories.
不要把 API Key 放入公共仓库。
恶意机器人会秒级扫描公开仓库中的密钥。
API keys, passwords, server names, database names are sensitive。
Exposed keys can provision IaaS resources.
泄露密钥可创建 IaaS 资源。
攻击者可用你的云密钥开服务器,账单算到你的账户上。
API key leakage has financial impact。
Commercial software may run on servers.
商业软件可运行在组织服务器上。
组织负责安装、配置、补丁和运行环境。
COTS still needs security assessment。
Software may be delivered over the Internet.
软件可能通过互联网交付。
SaaS 下很多责任在提供商,但组织仍要理解合同、配置和数据责任。
Shared responsibility applies。
Open-source software may be part of larger systems.
开源软件可能是大型系统组件。
开源不是天生不安全,但要跟踪版本、漏洞和维护状态。
COTS often incorporates OSS。
SLAs define service levels.
SLA 定义服务级别。
关键服务、数据库、应用、数据线路都可用 SLA 明确可用性和响应。
SLA supports third-party assurance。
关系数据库由表、行、列和键构成,SQL 提供数据定义、查询和修改能力。事务必须满足 ACID,确保数据在并发和失败场景下保持一致。
Relational databases use tables.
关系数据库使用表。
表由行和列构成,是 RDBMS 的基本结构。
Table also called relation。
A primary key uniquely identifies a row.
主键唯一标识一行。
候选键可唯一标识记录,主键是设计者选定的那个。
Primary key purpose 是常考选择题。
SQL provides a consistent interface.
SQL 提供一致接口。
用于存储、检索、修改数据和管理数据库结构。
SQL granularity of authorization 是安全特性。
DDL creates and modifies database structure.
DDL 创建和修改数据库结构。
例如创建表、修改字段、定义索引。
DDL = Data Definition Language。
DML manipulates data.
DML 操作数据。
查询、插入、更新、删除数据属于 DML。
DML = Data Manipulation Language。
Normalization reduces redundancy.
规范化减少冗余。
按 normal forms 组织表,提升一致性和维护性。
Normalization = bring tables into normal forms。
Transactions ensure data integrity.
事务确保数据完整性。
银行转账必须加钱和扣钱都成功,否则全部回滚。
Commit and rollback are transaction concepts。
Transactions require ACID characteristics.
事务需要 ACID 特性。
原子性、一致性、隔离性、持久性。
Atomicity, Consistency, Isolation, Durability。
数据库安全不仅是账号权限,还包括多级安全、视图、并发、聚合、推断、分区、多实例、NoSQL 安全模型和专家系统等概念。
Multilevel databases contain different classifications.
多级数据库包含不同密级信息。
同一个数据库里可能有公开、机密、秘密等不同级别数据。
Database contamination is a multilevel concern。
Views restrict access to attributes and rows.
视图限制属性和行访问。
用户看到的是 SQL 查询呈现的子集,而不是整张真实表。
Views are stored as SQL commands, not data tables。
Concurrency uses locks.
并发使用锁。
一个用户修改数据时,锁定相关项防止其他用户同时改变。
Locks preserve integrity during simultaneous access。
Aggregation combines lower-level information.
聚合组合低级别信息。
单项数据不敏感,合在一起可能推导出高敏信息。
Aggregation attack = combine data to reveal sensitive info。
Inference combines available information.
推断组合可见信息。
用户从合法可见数据推理出不该知道的敏感事实。
Inference differs from aggregation but related。
Partitioning splits a database into parts.
分区把数据库拆成多个部分。
按安全需求分割数据,降低聚合和推断风险。
Partitioning can counter inference/aggregation。
Polyinstantiation allows identical keys.
多实例允许相同主键记录。
不同安全级别用户看到不同版本,避免从缺失记录推断秘密。
Polyinstantiation defends against inference。
NoSQL uses nonrelational models.
NoSQL 使用非关系模型。
键值、文档、图、列族的安全模型可能不同;专家系统由知识库和推理引擎组成。
Expert system = knowledge base + inference engine。