首页 › 技术专题 › 安全架构

平台安全架构与数据合规

安全不是上线后补的课。账号四层防线、传输与存储加密、合规四问、应急演练——这篇按「前置」原则组织,每条都给验收标准。

Home › Tech › Security

Security architecture and data compliance

Security is not a post-launch patch. Four defensive layers for accounts, encryption in transit and at rest, the four compliance questions, and incident drills — organized around one principle: build it in.

安全投入的特点是:花的时候看不见回报,出事的时候全是回报的反面。包网平台涉及会员资产与个人数据,安全架构必须在设计阶段就进场。这篇按账号、加密、合规、应急四块拆。

账号体系:四层防线

  1. 密码层。bcrypt 或 argon2 哈希加盐,禁止明文和可逆加密。密码策略别过度——强制 90 天改密码的用户会把密码贴在显示器上,这是被反复验证过的反效果。
  2. 会话层。登录态有效期分级:普通操作 7 天,敏感操作(改绑、提现类)要求二次验证。异地登录提醒。全站 HTTPS,cookie 带 Secure 和 HttpOnly。
  3. 权限层。角色最小授权,后台操作全量审计日志。红线:任何单一角色不能同时管「资金数据」和「权限配置」——这两件事在一个手里,内部风险就没有上限。
  4. 异常层。登录失败锁定(5 次锁 15 分钟)、撞库检测(同 IP 多账号尝试)、机器人行为识别。这一层是和「批量注册、扫号」对抗的主战场。

加密:两个环节

传输层:TLS 全站覆盖,没有商量余地。证书自动续期(Let's Encrypt 加 certbot 就够),别让证书过期成为故障来源。

存储层:敏感字段(手机号、证件号)落库加密,密钥与数据分离存放——密钥在配置服务里,数据在库里,攻破数据库的人拿不到明文。展示层脱敏(138****5678),日志层屏蔽,备份同密级。保留期限写进策略,到期自动清理——「永久留存」是最常见的违规形态。

合规四问

不构成法律意见,但技术侧准备材料时先回答这四个问题,法务的工作量能减一半:

  1. 采集了哪些字段,每个字段的必要性依据是什么?(答不上必要性的字段,删。)
  2. 数据存在哪个地域,跨境吗?跨境的话走什么评估?
  3. 谁能看到哪些字段,权限矩阵在哪,审计日志保留多久?
  4. 用户要求删除时,多长时间能删干净,备份也删吗?

第四问最容易被忽略,也最容易在检查时露馅。备份的删除策略要和主库一致,这需要在架构设计时就写清楚。

应急演练清单

  • 每季度一次:模拟数据库故障,演练主备切换,记录切换时长(目标 5 分钟内)
  • 每半年一次:模拟会员数据泄露事件,演练通报流程、密码强制重置、日志取证
  • 每次演练后:预案修订,责任到人,下次演练验证修订有效

没演练过的预案等于没有预案。真实故障现场不是整理思路的地方,是执行肌肉记忆的地方。

安全与架构、接口的交叉点

接口层的验签与密钥轮换,是账号防线在系统边界的延伸,详见API对接指南。多可用区部署、密钥管理服务的容灾,属于架构议题,见高可用架构。数据跨境与多语言平台的关系,在多语言实务里讨论过。合规是上线检查的阻断项——这条原则也写进了周期拆解的测试阶段。

安全预算怎么排

常被问到「安全上该花多少钱」。一个可参考的锚点:安全投入占搭建总预算的一到两成,低于一成的项目,大概率把钱省在了看不见的地方;高于两成,要么是合规要求特殊,要么是被供应商吓的。分配上建议倒着排:先保账号体系和数据加密(出事就是事故级),再补异常检测(对抗批量注册),最后才是渗透测试这类锦上添花。顺序反了,就是把钱花在了报告好看、防线漏风的组合上。

Security spending has an awkward profile: invisible when nothing happens, and its absence is the whole story when something does. A platform holding member assets and personal data cannot treat security as a post-launch course. This page covers four blocks: accounts, encryption, compliance and incident response.

Accounts: four defensive layers

  1. Password layer. bcrypt or argon2 with salts; plaintext and reversible encryption are non-starters. Do not over-engineer password policy — forced 90-day rotation reliably produces passwords on sticky notes. This has been verified more times than anyone would like.
  2. Session layer. Tiered session lifetimes: 7 days for ordinary actions, step-up verification for sensitive ones (rebinding contacts, withdrawal-type operations). Login alerts for new locations. HTTPS everywhere; cookies carry Secure and HttpOnly.
  3. Permission layer. Least privilege by role, full audit logging on back-office actions. One hard line: no single role may hold both financial data access and permission administration — combined, they remove the ceiling on insider risk.
  4. Anomaly layer. Lockout on failed logins (5 attempts, 15 minutes), credential-stuffing detection (many accounts from one IP), bot-behavior recognition. This layer is the front line against bulk registration and account scanning.

Encryption: two places

In transit: TLS across the entire site. Not negotiable. Automate certificate renewal — an expired certificate should never be an outage cause.

At rest: sensitive fields (phone numbers, identity numbers) encrypted at write time, with keys stored separately from data — keys in a configuration service, data in the database, so someone who breaches the database holds no plaintext. Masking at the display layer (138****5678), suppression in logs, backups at the same classification. Retention periods belong in policy with automatic expiry — "keep forever" is the most common violation pattern there is.

The four compliance questions

This is not legal advice, but answering these four before the lawyers arrive halves their workload:

  1. Which fields do you collect, and what is the necessity basis for each? (No basis, no field.)
  2. In which region does the data live, and does it cross borders? If so, under which assessment?
  3. Who can see which fields? Where is the permission matrix, and how long are audit logs retained?
  4. When a user requests deletion, how fast is it complete — and does it include backups?

The fourth question is the most overlooked and the most exposed under inspection. Backup deletion must match primary-store policy, and that has to be designed in from the start.

Incident drill checklist

  • Quarterly: simulate a database failure, rehearse the failover, and record the switch time (target: under 5 minutes)
  • Semi-annually: simulate a member-data breach — rehearse notification flow, forced password reset and log forensics
  • After every drill: revise the playbook, assign owners, and verify the revision in the next drill

An untested playbook is no playbook. A live incident is where you execute muscle memory, not where you organize your thoughts.

How to size the security budget

We are often asked what security "should" cost. One usable anchor: one to two tenths of the total build budget. Below one tenth, the money was almost certainly saved in places no one can see. Above two tenths, either the compliance regime is genuinely unusual or a vendor did an effective job of frightening someone. Within the budget, allocate in reverse order of glamour: accounts and encryption first (failures here are incident-grade), anomaly detection second (the fight against bulk registration), and penetration testing last, as polish. Reverse that order and you get reports that read well in front of a defense line with holes in it.

Where security crosses architecture and interfaces

Signature verification and key rotation at the interface layer are the account defense extended to the system boundary — details in the API integration guide. Multi-zone deployment and key-management failover are architecture topics, covered in high availability. How cross-border data concerns multilingual platforms was discussed in the multilingual practice. And compliance is a blocking item in launch checks — a principle also written into the testing stage of the timeline breakdown.

安全自查不知道从哪做起?

按四块清单逐项过,存疑的条目来聊。

立即联系我们

Not sure where to start the security review?

Walk the four checklists in order — and bring the items you are unsure about.

Contact us