WikifitaGitHub live67e8de5
outro · co-fita/co-fita-sdlc-protocol

Alefita's Secure SDLC: The 7-Phase Lifecycle

Complete Secure SDLC methodology: 7-phase lifecycle, Security by Design, Green-Mile analysis, Red-to-Blue Team loop, analytical patterns, and AI security framework.

Baixar raw

Alefita's Secure SDLC Protocol

Source: SDLC_PROTOCOL_REPORT.md (2026-07-22), playbook_bairesdev_appsec_alefita.md Cross-references: co-fita-green-mile, co-fita-red-team-blue-team, co-fita-harness, clickfix-attack-chain, kaggle-agent-security


The 7-Phase Lifecycle

The Secure SDLC is not a checklist. It is a system of feedback loops where each phase feeds forward into the next and backward into previous phases when incidents occur. This is the methodology Alefita practiced at RD Saude, refined through CAMDOM, and formalized in the BairesDev AppSec playbook.

graph LR
    P1[1. Planning] --> P2[2. Design]
    P2 --> P3[3. Development]
    P3 --> P4[4. Build & Release]
    P4 --> P5[5. Runtime Testing]
    P5 --> P6[6. Operations]
    P6 --> P7[7. Feedback & Control]
    P7 -.->|"back-feed"| P1
    P7 -.->|"back-feed"| P2
    P6 -.->|"incident back-feed"| P2

Phase 1: Planning

Classify data, business actions, regulatory context, threat surface and security requirements. Identify what must never happen and what evidence will be required.

The Six Questions

Before implementation begins, six questions must be answered:

  1. What data and business actions are at stake?
  2. Who is allowed to perform each action?
  3. Which component owns the authorization decision?
  4. What happens when the client is modified or bypassed?
  5. Which trust boundaries exist between mobile, gateway, proxy, and core services?
  6. What evidence will prove that the intended control is active?

Question 4 is the most important. It is the question that produced the co-fita-green-mile finding.

Practice Evidence

RD Saude: Before any API or mobile feature reached development, the security engineering function classified data types (PII, payment cards, auth tokens), business actions (account takeover, billing manipulation), and regulatory exposure (LGPD, PCI DSS). This was structured conversation between security, product, and engineering leads -- not a form-filling exercise.

LuizaLabs: The SuperApp feature inheritance demonstrates planning as a decision point. Alefita diagnosed architectural fragility that would compound security and maintenance costs. Shipping now and accumulating debt vs. investing in the foundation -- this is a planning-phase security decision.

CAMDOM: Planning required mapping an entirely new threat surface: physical proximity, BLE radio range, cross-platform protocol differences, offline constraints, and the social safety problem. Security requirements -- zero data collection, no cloud dependency, hardware-level protection -- were defined before a single line of code. See camdom-architecture.


Phase 2: Design

Map trust boundaries, identities, service ownership, authorization decisions, secrets, failure modes and abuse cases. Review API contracts and architecture before implementation.

Security by Design

The core principle: make the safe architecture the default architecture. When the gateway enforces authentication, authorization, input validation, and rate limiting by default, individual teams do not need to rediscover the same security decisions for every new endpoint.

API Governance as Control Plane

The RD API Governance Playbook is the architectural expression of Security by Design:

MechanismWhat It Encodes
Separation of concernsGateway handles auth/authz/validation; services handle business logic
OpenAPI contractsMachine-readable interface definition (control surface, not documentation)
HATEOASClients discover actions through links, not leaked implementation details
Consultative onboardingSecurity function as enabler, not gatekeeper
Gateway policySecurity decisions encoded once, enforced everywhere

The scaling insight: AppSec scales when teams do not need to rediscover the same security decisions for every API. The gateway policy, the contract standard, the onboarding process -- these are infrastructure that encode security decisions once and enforce them everywhere.

CAMDOM Design Outputs

The design phase produced:

  • Leader election protocol for BLE role assignment (highest-value-wins)
  • Platform-specific advertising value ranges for cross-platform disambiguation
  • Session-based connection handshake with UUID v4 identifiers
  • Mutual disconnection protocol requiring all parties to agree
  • RSSI proximity detection using rolling windows
  • Privacy by design: zero analytics, zero telemetry, zero network calls beyond BLE

Phase 3: Development

Use secure coding guidance, peer review, SAST, SCA, secret scanning, tests and small changes. Generated code must receive the same or stronger verification as human-written code.

AI-Generated Code as Untrusted Input

The playbook's position is unambiguous: treat model output as untrusted input. Require tests, linting, SAST, SCA, secret scanning, dependency validation, review, and CI gates.

Why: AI-generated code may contain insecure patterns absorbed from training data, hallucinate non-existent or vulnerable dependencies, leak credentials embedded in context, implement authentication incorrectly while appearing syntactically correct, or use deprecated/vulnerable API patterns.

The pipeline: AI-generated code enters the same pipeline as human code. Same tests. Same SAST. Same SCA. Same secret scanning. Same review. Same CI gates. Plus additional controls for data boundaries and agent permissions.

Real-World Development Under Pressure

The CAMDOM codebase (429 commits, 8,967 lines) reveals what shipping under real constraints looks like:

StrengthWeakness
TypeScript strict mode enabled1,877-line god object
Clean naming conventionsZero test coverage
Elegant generator-based animation engine115 lines of commented-out code
429 commits of iteration13+ magic numbers

This is honest. The playbook's development phase standards exist precisely because these pressures produce predictable failure modes. The code quality score of 3.6/10 is not a failure -- it is a documented trade-off under Cannes Lions submission timeline pressure.


Phase 4: Build and Release

Use reproducible artifacts, dependency validation, policy gates, environment controls and explicit exception handling.

Risk-Based Blocking

The playbook distinguishes between blocking criteria and scanner severity. A finding blocks release based on:

FactorQuestion
ExploitabilityHow easy is it to exploit?
ExposureIs the component internet-facing?
Asset sensitivityWhat data is at risk?
Business impactWhat is the consequence?
ConfidenceHow certain is the finding?
Compensating controlsAre there mitigations in place?
Time to remediateHow long until a fix is available?

Scanner severity alone is insufficient.

Exception Handling

When a finding does not block release, it requires an expiring exception with an owner and a retest plan. Exceptions are not baselines -- they are temporary deviations that must be resolved or escalated.

CAMDOM example: The RSSI proximity feature is disabled (115 lines of commented-out code) rather than removed. This is a documented exception: the feature was not reliable enough for production but represents a capability worth preserving. The code exists as an explicit exception, not accidental deletion.


Phase 5: Runtime Testing

Combine DAST, IAST, API authorization tests, manual testing and threat-informed regression. Static and dynamic findings answer different questions; neither is sufficient alone.

The Method Comparison

MethodStrengthWeakness
SASTInsecure patterns, data-flow problems, earlyWeak when exploitability depends on runtime config
DASTObservable runtime behavior, config issues, attack pathsRequires realistic environments, careful triage
IASTRuntime behavior with code contextDepends on instrumentation and coverage
SCADependency inventory, vulnerability and license trackingMust pair with lockfile integrity and SBOM
Manual/AdversarialBusiness-logic abuse, authorization chains, attacker creativityCannot be automated; requires reasoning

The Critical Insight

Automated tools increase coverage; they do not eliminate reasoning. Human testing is needed for:

  • What happens when a mobile client is instrumented with Frida
  • When authorization is tested across multiple object types and roles
  • When an attacker chains two individually low-severity findings into a high-impact exploit

This is exactly what happened in co-fita-green-mile: the IDOR vulnerability was exploitable not because of a single bug, but because of a chain of architectural gaps that no single scanner could model.


Phase 6: Operations

Monitor relevant abuse signals, keep vulnerability intake connected to ownership, patch within risk-based SLAs, rehearse rollback and feed incidents back into design and tooling.

ClickFix: Operations in Real Time

The clickfix-incident-response on 2026-06-25 demonstrated the operations phase under live attack:

MetricThis IncidentIndustry Average
First alert to AI response1 second--
Alert to malicious process identified16 seconds--
Alert to LaunchAgent persistence found101 seconds--
Alert to system declared clean160 seconds70 minutes (containment)
Full forensic chain revealed~24 minutes207 minutes (detection)

The 160-second containment was possible because the operational phase was not improvised. The response followed the structured loop: identify persistence, understand the respawn mechanism (KeepAlive: true), unload the LaunchAgent before killing processes, verify artifacts, document the full chain.

The back-feed: The operations phase feeds into design. The ClickFix attack revealed that expired domains in trusted repositories (supply chain risk) are a permanent threat surface that must be modeled in the planning phase.


Phase 7: Feedback and Control Encoding

Turn the lesson into a reusable control, standard or pipeline check. Measure whether the control reduces meaningful risk without destroying delivery flow.

The Seven Requirements

A finding is not complete when a ticket exists. It needs:

  1. Clear affected asset and owner
  2. Reproducible evidence
  3. Severity tied to exposure and business impact
  4. Root-cause diagnosis
  5. Remediation or compensating control
  6. Retest and regression evidence
  7. A durable lesson for standards, templates, or automation

What Separates Security Engineers from Pentesters

The pentester delivers a finding. The security engineer encodes the finding into a control that prevents the entire class of vulnerability from recurring.

This seventh phase is the through-line across all of Alefita's work:

ProjectControl Encoded
Green-Mile5-layer fix model (client, gateway, service, data, process)
CAMDOMBLE proximity protocol as a reusable pattern for consent
ClickFixForensic documentation + longitudinal monitoring protocol
Co-Fitaco-fita-governance -- governance proposals as encoded operational lessons
Wikifitawikifita -- OKF as encoded knowledge management standards

Vulnerability Management as System

The playbook defines vulnerability management not as "find and fix" but as a complete lifecycle:

graph LR
    INT[Intake<br/>Triage + Ownership] --> DIAG[Diagnosis<br/>Root Cause]
    DIAG --> REM[Remediation<br/>Fix at Correct Layer]
    REM --> VER[Verification<br/>Retest + Regression]
    VER --> ENC[Encoding<br/>Durable Control]
    ENC --> MON[Monitoring<br/>Track Recurrence]
    MON -.->|"feedback"| INT
StageWhat Happens
IntakeFindings triaged with clear asset identification, ownership assignment, severity tied to business context
DiagnosisRoot cause identified. An IDOR is not just a bad endpoint -- it may indicate missing ownership semantics, weak gateway policy, absent API standards
RemediationFix applied at the correct layer (see co-fita-green-mile). Compensating controls documented when immediate remediation is not possible
VerificationRetest with regression evidence. Finding not closed until proof exists that fix works
EncodingLesson becomes a standard, template, pipeline check, or design pattern

The Five Analytical Patterns

The playbook identifies five recurring decision-making patterns that appear across every project in Alefita's career.

Pattern 1: Move from Symptom to System

Ask whether an observed failure is local or structural.

CaseSymptomSystem Diagnosis
Green-MileIDOR in address proxyMissing ownership semantics, weak gateway policy, absent API standards
ClickFixCompromised clipboardSupply chain trust model treats repo links as permanent
CAMDOMPrivacy breach riskApps depend on cloud services, software locks, single-device protections
LuizaLabs"Near-finished" fragile featureDebt decision, not shipping decision

Pattern 2: Preserve the Future System

Accept schedule cost to avoid shipping architecture that would multiply future costs.

CaseDecisionRationale
LuizaLabs SuperAppSubstantial refactor over shippingTotal cost of ownership and risk compounding
CAMDOMFull rewrite in final 15 daysCleaner Expo Modules abstraction; original architecture would accumulate workarounds
RD API GovernanceOpenAPI + HATEOAS + centralized gatewayPer-team security decisions reduced from O(n) to O(1)

Pattern 3: Make Trade-offs Explicit

Separate hard constraints from preferences. Distinguish temporary exceptions from new baselines. Ask who owns the risk.

Release blocking formulation: "I use risk, not scanner severity alone: exploitability, exposure, asset sensitivity, business impact, confidence, compensating controls and time to remediate. I block when residual risk exceeds the agreed threshold; otherwise I document an expiring exception with an owner and retest plan."

Pattern 4: Learn Through Instrumentation

Conclusions are based on evidence, not intuition alone.

ProjectEvidence Sources
ClickFixSafari History.db, LaunchAgent plists, process listings, blockchain transactions
CAMDOMRSSI rolling windows, explicit state machine transitions, deterministic election algorithms
RD SaudeBurp Suite, Frida hooks, JADX inspection, postmortem analysis
Kaggle7 attack primitives identified through structured experimentation

Pattern 5: Turn Knowledge into Infrastructure

Create playbooks, templates, governance rules, pipeline controls so expertise becomes organizational capability.

ProjectInfrastructure Created
RD API GovernanceLiving document encoding security decisions as architectural standards
CAMDOMBLE protocol specification, leader election algorithm, session handshake -- reusable patterns
Co-Fitaco-fita-governance -- Centralismo Democratico turns failures into governance proposals
WikifitaOKF standard, structured memory, constitutional directives

AI Security Framework

Agentic Workflow Controls

For agents that can read repositories, call tools, or write code, the playbook defines seven control categories:

ControlPurposeCo-Fita Implementation
Least-privilege identitiesAgent operates with minimum necessary permissionsWorker agents scoped to roles; cannot self-promote
Tool allowlistsAgent can only invoke approved toolsMCP server capabilities governed by proposal categories
Sandboxing and data boundariesAgent cannot access data outside its scopeOperations scoped to project directories
Explicit approval pointsHuman reviews before high-risk actionsChancela system
Output validationAgent output verified before consumptionElo tournament debate
Reproducible tracesEvery action logged and auditableAppend-only JSONL logs
Kill switches and rollbackAbility to halt and revertVeto mechanism

Connection to Kaggle Competition

The kaggle-agent-security competition (OpenAI, Google, IEEE) validates this framework empirically. The four measured predicates map directly to playbook controls:

PredicateSeverityPlaybook Control
EXFILTRATION5Sandboxing + data boundaries + tool allowlists
UNTRUSTED_TO_ACTION5/4Explicit approval points + least-privilege identities
DESTRUCTIVE_WRITE4Sandboxing + output validation
CONFUSED_DEPUTY3Explicit approval points (human-in-the-loop)

The 7 Attack Primitives

From attack-primitives, seven behavioral patterns in language models that can be exploited:

  1. Identity Steering -- Models accept any identity the prefill assigns
  2. Decision-Collapsing -- Models silently re-prioritize multi-component instructions
  3. Urgency Vectors -- Urgency framing increases probability of destructive actions
  4. CoT Post-Hoc Rationalization -- Chain-of-thought rationalizes after the forward pass decides
  5. ROP Gadget Chains -- Models reuse existing reasoning features for emergent behaviors
  6. Linguistic Heterogeneity -- Safety guardrails are trained predominantly on English
  7. Steganography in CoT -- Models encode hidden information in reasoning traces

Each primitive has a corresponding defensive control in the playbook's framework.


Career Synthesis

The SDLC protocol is not theoretical. It is demonstrated practice across five years of progressive capability accumulation:

PeriodRoleCapability Layer
2019-2022Mobile Developer, Tech LeadFoundation: build, debug, ship production software
2022-2024Tech Lead Cyber Security (RD Saude)Security: pentesting, Security by Design, API governance
2024CAMDOM (Solo Developer)Product security: BLE mesh, cross-platform, privacy by design
2025-presentR&D Specialist (LuizaLabs)AI security: Gen AI, ML, React Native, engineering judgment
2026Research (Kaggle, ClickFix, Co-Fita)AI governance: agent security, APT forensics, governance systems

Each role added capability without abandoning previous capability. The differentiator is the ability to move between abstraction levels: API contract, mobile binary, CI pipeline, cloud boundary, organizational ownership, and business consequence.

"I work across the whole security lifecycle: I find what can be abused, understand why the architecture allowed it, fix it at the right layer, and convert the lesson into a control that teams can repeat."


This document is alive. It evolves as the research evolves. Challenge it. Improve it. That is the protocol.