mason-keller
feat: add autonomous biological dna microarray biosecurity attestation gate (v1.58.0)
ff02c4b Download src/dna/dna_microarray_audit.ts from mason-keller/vulnforge-mcp: direct link, hf CLI and curl.
- Browser
- Download file 33.1 kB
-
https://huggingface.co/mason-keller/vulnforge-mcp/resolve/main/src/dna/dna_microarray_audit.ts
- Command line
-
hf download hf://mason-keller/vulnforge-mcp/src/dna/dna_microarray_audit.ts
-
curl -L -o dna_microarray_audit.ts https://huggingface.co/mason-keller/vulnforge-mcp/resolve/main/src/dna/dna_microarray_audit.ts
33.1 kB
| /** | |
| * VulnForge MCP - Autonomous Biological DNA Microarray Biosecurity & Digital Watermark Attestation Gate | |
| * @module dna/dna_microarray_audit | |
| * | |
| * Implements static and dynamic architectural security auditing for: | |
| * 1. VF-DNAMICRO-001 (CRITICAL, CWE-327): Synthetic Gene Synthesis Pathogen Screening Bypass & Select Agent Database Evaporation | |
| * 2. VF-DNAMICRO-002 (CRITICAL, CWE-347): Biological Digital Watermark Payload Provenance Absence & Unsigned Cryptographic Signature | |
| * 3. VF-DNAMICRO-003 (CRITICAL, CWE-353): Customer Identity & Legitimate End-User Screening Attestation Failure (Know-Your-Customer / KYC) | |
| * 4. VF-DNAMICRO-004 (HIGH, CWE-284): Dual-Use Research of Concern (DURC) Gene Perturbation & Virulence Enhancer Masking | |
| * 5. VF-DNAMICRO-005 (HIGH, CWE-400): Microarray Hybridization Spot Density Over-Saturation & Optical Fluorophore Bleed | |
| * 6. VF-DNAMICRO-006 (HIGH, CWE-208): Ephemeral Codon Optimization Evasion & Homology Scrambling Side-Channel | |
| * 7. VF-DNAMICRO-007 (HIGH, CWE-294): Synthesis Nonce Replay & Stale Biosecurity Certificate Re-Use | |
| * 8. VF-DNAMICRO-008 (HIGH, CWE-754): Synthesis Equipment Fail-Open Posture & Physical Gene Foundry Tamper Lockdown Failure | |
| */ | |
| import { | |
| FuzzMutationCase, | |
| PatchRecommendation, | |
| SecurityFinding, | |
| DnaMicroarrayArtifactFormat, | |
| DnaMicroarrayAuditInput, | |
| DnaMicroarrayAuditResult, | |
| DnaMicroarrayAuditSummary, | |
| DnaMicroarrayFindingCode, | |
| DnaMicroarrayBiosecurityPolicy | |
| } from '../types/index.js'; | |
| export const DEFAULT_DNA_MICROARRAY_BIOSECURITY_POLICY: DnaMicroarrayBiosecurityPolicy = { | |
| policyVersion: '1.58.0', | |
| pathogenHomologyScreening: { | |
| enforceSelectAgentScreening: true, | |
| minScreeningWindowBp: 200, | |
| maxEvalueThreshold: 1e-10, | |
| requireSixFrameTranslation: true | |
| }, | |
| digitalWatermarkProvenance: { | |
| enforceDigitalWatermarking: true, | |
| requireEd25519WatermarkSignature: true, | |
| minWatermarkPayloadBits: 128, | |
| disallowUnwatermarkedConstructs: true | |
| }, | |
| customerKycAttestation: { | |
| enforceInstitutionalKyc: true, | |
| requireBslVerification: true, | |
| requireDualAuthorization: true, | |
| disallowUnauthenticatedRecipients: true | |
| }, | |
| durcSplitSynthesisDefense: { | |
| enforceMultiFragmentAssemblyCheck: true, | |
| maxCumulativePathogenCoveragePct: 15.0, | |
| disallowSplitGeneOrders: true | |
| }, | |
| microarrayDensityCrosstalk: { | |
| enforceSpotDensityLimits: true, | |
| maxProbeSpotDensityPct: 90.0, | |
| maxFluorophoreCrosstalkPct: 3.0, | |
| requireNegativeControlProbes: true | |
| }, | |
| codonScramblingDetection: { | |
| enforceAminoAcidHomologyScreening: true, | |
| disallowSynonymousEvasion: true, | |
| minProteinIdentityThresholdPct: 80.0 | |
| }, | |
| synthesisNonceLifecycle: { | |
| enforceFreshSynthesisNonces: true, | |
| maxNonceLifetimeSeconds: 86400, | |
| requireMonotonicOrderCounter: true, | |
| disallowStaleBiosecurityCerts: true | |
| }, | |
| equipmentFailClosed: { | |
| enforceFailClosedSynthesisAbort: true, | |
| requireAutomaticReagentPurge: true, | |
| maxEmergencyLockdownResponseMs: 500, | |
| zeroizeSynthesisBufferOnAbort: true | |
| } | |
| }; | |
| export function detectDnaMicroarrayFormat(content: string): DnaMicroarrayArtifactFormat { | |
| if (!content || typeof content !== 'string') { | |
| return 'UNKNOWN'; | |
| } | |
| const trimmed = content.trim(); | |
| // Guard against cross-contamination from other quantum/biochemical engines | |
| if ( | |
| trimmed.includes('flux_qubit_calibration') || | |
| trimmed.includes('readout_cavity') || | |
| trimmed.includes('magnetic_shielding_telemetry') || | |
| trimmed.includes('homopolymerConstraint') || | |
| trimmed.includes('errorCorrectionCoding') || | |
| trimmed.includes('JosephsonJunctionSecurityPolicy') || | |
| trimmed.includes('TerahertzSecurityPolicy') | |
| ) { | |
| return 'UNKNOWN'; | |
| } | |
| if ( | |
| trimmed.includes('dna_microarray_order') || | |
| trimmed.includes('microarray_order_manifest') || | |
| trimmed.includes('synthetic_gene_order') || | |
| trimmed.includes('oligo_synthesis_request') || | |
| trimmed.includes('DNA_MICROARRAY_ORDER') || | |
| trimmed.includes('screen_window_bp') || | |
| trimmed.includes('homology_e_value') || | |
| (trimmed.startsWith('{') && trimmed.includes('sequence') && trimmed.includes('order_id')) | |
| ) { | |
| return 'DNA_MICROARRAY_ORDER_JSON'; | |
| } | |
| if ( | |
| (trimmed.startsWith('>') || trimmed.includes('\n>')) && | |
| (/[ACGTUNacgtun\r\n\s]{20,}/.test(trimmed) || trimmed.includes('synthetic_construct')) | |
| ) { | |
| return 'SYNTHETIC_GENE_FASTA'; | |
| } | |
| if ( | |
| trimmed.includes('digital_watermark_spec') || | |
| trimmed.includes('watermark_payload') || | |
| trimmed.includes('watermark_signature') || | |
| trimmed.includes('watermark_ed25519') || | |
| trimmed.includes('DIGITAL_WATERMARK') || | |
| trimmed.includes('biosecurity_watermark') | |
| ) { | |
| return 'DIGITAL_WATERMARK_SPEC'; | |
| } | |
| if ( | |
| trimmed.includes('pathogen_screening_report') || | |
| trimmed.includes('biosecurity_homology_report') || | |
| trimmed.includes('select_agent_match') || | |
| trimmed.includes('PATHOGEN_SCREENING_REPORT') || | |
| trimmed.includes('assembly_screening') || | |
| trimmed.includes('customer_screening') || | |
| trimmed.includes('codon_optimization') || | |
| trimmed.includes('synthesis_nonce_validation') || | |
| trimmed.includes('gene_foundry_id') | |
| ) { | |
| return 'PATHOGEN_SCREENING_REPORT_JSON'; | |
| } | |
| if ( | |
| trimmed.includes('hybridization_map') || | |
| trimmed.includes('probe_spot_density') || | |
| trimmed.includes('fluorophore_crosstalk') || | |
| trimmed.includes('spot_intensity_cy3_cy5') || | |
| trimmed.includes('MICROARRAY_HYBRIDIZATION') || | |
| trimmed.includes('microarray_spot_density_pct') | |
| ) { | |
| return 'MICROARRAY_HYBRIDIZATION_MAP'; | |
| } | |
| if ( | |
| trimmed.includes('biosecurity_policy') || | |
| trimmed.includes('DnaMicroarrayBiosecurityPolicy') || | |
| trimmed.includes('dna_microarray_biosecurity') || | |
| (trimmed.startsWith('{') && | |
| trimmed.includes('pathogenHomologyScreening') && | |
| trimmed.includes('digitalWatermarkProvenance')) | |
| ) { | |
| return 'BIOSECURITY_POLICY_JSON'; | |
| } | |
| return 'UNKNOWN'; | |
| } | |
| export function isDnaMicroarrayContent(content: string): boolean { | |
| return detectDnaMicroarrayFormat(content) !== 'UNKNOWN'; | |
| } | |
| export function synthesizeDnaMicroarrayPolicy( | |
| targetFile: string = 'dna_microarray_biosecurity_policy.json', | |
| findings: SecurityFinding[] = [] | |
| ): DnaMicroarrayBiosecurityPolicy { | |
| const policy: DnaMicroarrayBiosecurityPolicy = JSON.parse( | |
| JSON.stringify(DEFAULT_DNA_MICROARRAY_BIOSECURITY_POLICY) | |
| ); | |
| for (const finding of findings) { | |
| const code = (finding.findingCode || finding.id) as DnaMicroarrayFindingCode; | |
| switch (code) { | |
| case 'VF-DNAMICRO-001': | |
| policy.pathogenHomologyScreening.enforceSelectAgentScreening = true; | |
| policy.pathogenHomologyScreening.minScreeningWindowBp = 200; | |
| policy.pathogenHomologyScreening.maxEvalueThreshold = 1e-10; | |
| policy.pathogenHomologyScreening.requireSixFrameTranslation = true; | |
| break; | |
| case 'VF-DNAMICRO-002': | |
| policy.digitalWatermarkProvenance.enforceDigitalWatermarking = true; | |
| policy.digitalWatermarkProvenance.requireEd25519WatermarkSignature = true; | |
| policy.digitalWatermarkProvenance.minWatermarkPayloadBits = 128; | |
| policy.digitalWatermarkProvenance.disallowUnwatermarkedConstructs = true; | |
| break; | |
| case 'VF-DNAMICRO-003': | |
| policy.customerKycAttestation.enforceInstitutionalKyc = true; | |
| policy.customerKycAttestation.requireBslVerification = true; | |
| policy.customerKycAttestation.requireDualAuthorization = true; | |
| policy.customerKycAttestation.disallowUnauthenticatedRecipients = true; | |
| break; | |
| case 'VF-DNAMICRO-004': | |
| policy.durcSplitSynthesisDefense.enforceMultiFragmentAssemblyCheck = true; | |
| policy.durcSplitSynthesisDefense.maxCumulativePathogenCoveragePct = 10.0; | |
| policy.durcSplitSynthesisDefense.disallowSplitGeneOrders = true; | |
| break; | |
| case 'VF-DNAMICRO-005': | |
| policy.microarrayDensityCrosstalk.enforceSpotDensityLimits = true; | |
| policy.microarrayDensityCrosstalk.maxProbeSpotDensityPct = 85.0; | |
| policy.microarrayDensityCrosstalk.maxFluorophoreCrosstalkPct = 2.5; | |
| policy.microarrayDensityCrosstalk.requireNegativeControlProbes = true; | |
| break; | |
| case 'VF-DNAMICRO-006': | |
| policy.codonScramblingDetection.enforceAminoAcidHomologyScreening = true; | |
| policy.codonScramblingDetection.disallowSynonymousEvasion = true; | |
| policy.codonScramblingDetection.minProteinIdentityThresholdPct = 85.0; | |
| break; | |
| case 'VF-DNAMICRO-007': | |
| policy.synthesisNonceLifecycle.enforceFreshSynthesisNonces = true; | |
| policy.synthesisNonceLifecycle.maxNonceLifetimeSeconds = 43200; | |
| policy.synthesisNonceLifecycle.requireMonotonicOrderCounter = true; | |
| policy.synthesisNonceLifecycle.disallowStaleBiosecurityCerts = true; | |
| break; | |
| case 'VF-DNAMICRO-008': | |
| policy.equipmentFailClosed.enforceFailClosedSynthesisAbort = true; | |
| policy.equipmentFailClosed.requireAutomaticReagentPurge = true; | |
| policy.equipmentFailClosed.maxEmergencyLockdownResponseMs = 300; | |
| policy.equipmentFailClosed.zeroizeSynthesisBufferOnAbort = true; | |
| break; | |
| } | |
| } | |
| return policy; | |
| } | |
| export async function auditDnaMicroarraySecurity( | |
| input: DnaMicroarrayAuditInput | |
| ): Promise<DnaMicroarrayAuditResult> { | |
| const content = input.content || ''; | |
| const filePath = input.filePath || 'dna_microarray_order.json'; | |
| const format = input.format || detectDnaMicroarrayFormat(content); | |
| const findings: SecurityFinding[] = []; | |
| const patchRecommendations: PatchRecommendation[] = []; | |
| // Parse structured data or analyze text lines | |
| let parsedJson: any = null; | |
| try { | |
| if (content.trim().startsWith('{') || content.trim().startsWith('[')) { | |
| parsedJson = JSON.parse(content); | |
| } | |
| } catch { | |
| parsedJson = null; | |
| } | |
| const enforceSelectAgent = input.enforceSelectAgentScreening !== false; | |
| const enforceWatermark = input.enforceDigitalWatermarking !== false; | |
| const enforceKyc = input.enforceInstitutionalKyc !== false; | |
| const enforceDurc = input.enforceMultiFragmentAssemblyCheck !== false; | |
| const enforceSpotDensity = input.enforceSpotDensityLimits !== false; | |
| const enforceCodon = input.enforceAminoAcidHomologyScreening !== false; | |
| const enforceNonce = input.enforceFreshSynthesisNonces !== false; | |
| const enforceFailClosed = input.enforceFailClosedSynthesisAbort !== false; | |
| // 1. VF-DNAMICRO-001 (CRITICAL, CWE-327): Pathogen Screening Bypass | |
| if (enforceSelectAgent) { | |
| const screeningDisabled = | |
| /("enforceSelectAgentScreening"\s*:\s*false|"screening_enabled"\s*:\s*false|bypass_pathogen_screening\s*[:=]\s*true)/i.test( | |
| content | |
| ) || | |
| (parsedJson?.pathogenHomologyScreening?.enforceSelectAgentScreening === false) || | |
| (parsedJson?.screening_enabled === false); | |
| const windowMatch = content.match(/(?:minScreeningWindowBp|screen_window_bp|window_size_bp)"?\s*[:=]\s*([0-9]+)/i); | |
| const windowTooSmall = | |
| (windowMatch && Number(windowMatch[1]) < 200) || | |
| (parsedJson?.pathogenHomologyScreening?.minScreeningWindowBp !== undefined && | |
| Number(parsedJson.pathogenHomologyScreening.minScreeningWindowBp) < 200) || | |
| (parsedJson?.screen_window_bp !== undefined && Number(parsedJson.screen_window_bp) < 200); | |
| const evalueMatch = content.match(/(?:maxEvalueThreshold|homology_e_value|e_value)"?\s*[:=]\s*([0-9eE.-]+)/i); | |
| const evalueTooHigh = | |
| (evalueMatch && Number(evalueMatch[1]) > 1e-10) || | |
| (parsedJson?.pathogenHomologyScreening?.maxEvalueThreshold !== undefined && | |
| Number(parsedJson.pathogenHomologyScreening.maxEvalueThreshold) > 1e-10) || | |
| (parsedJson?.homology_e_value !== undefined && Number(parsedJson.homology_e_value) > 1e-10); | |
| if (screeningDisabled || windowTooSmall || evalueTooHigh) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-001', | |
| findingCode: 'VF-DNAMICRO-001', | |
| title: 'Synthetic Gene Synthesis Pathogen Screening Bypass & Select Agent Database Evaporation', | |
| severity: 'CRITICAL', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-327', | |
| target: filePath, | |
| description: | |
| 'Pathogen homology screening against Select Agents and Toxins is disabled, uses a window < 200 bp, or has an excessively permissive E-value threshold, enabling unregulated synthesis of high-consequence biological agents.', | |
| evidence: `Screening disabled: ${screeningDisabled}, Window violation: ${windowTooSmall}, E-value threshold violation: ${evalueTooHigh}`, | |
| impact: | |
| 'Enables unauthorized synthesis of regulated viral or bacterial toxins bypassing international biosecurity frameworks.', | |
| remediation: | |
| 'Mandate continuous Select Agent and Toxin homology screening with a minimum 200 bp window and E-value <= 1e-10.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Enforce Select Agent pathogen screening with 200 bp minimum window and E-value <= 1e-10.' | |
| }); | |
| } | |
| } | |
| // 2. VF-DNAMICRO-002 (CRITICAL, CWE-347): Biological Digital Watermark Payload Provenance Absence | |
| if (enforceWatermark) { | |
| const watermarkMissing = | |
| /("enforceDigitalWatermarking"\s*:\s*false|"digital_watermark_present"\s*:\s*false|"watermark_signature_present"\s*:\s*false|watermark_enabled\s*[:=]\s*false)/i.test( | |
| content | |
| ) || | |
| (parsedJson?.digitalWatermarkProvenance?.enforceDigitalWatermarking === false) || | |
| (parsedJson?.digital_watermark_present === false) || | |
| (parsedJson?.watermark_signature_present === false) || | |
| (content.includes('watermark_signature') && content.includes('unsigned_mock_signature')); | |
| const signatureMissing = | |
| /("requireEd25519WatermarkSignature"\s*:\s*false|signature_algorithm\s*[:=]\s*"none")/i.test( | |
| content | |
| ); | |
| if (watermarkMissing || signatureMissing) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-002', | |
| findingCode: 'VF-DNAMICRO-002', | |
| title: 'Biological Digital Watermark Payload Provenance Absence & Unsigned Cryptographic Signature', | |
| severity: 'CRITICAL', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-347', | |
| target: filePath, | |
| description: | |
| 'Synthetic DNA sequence lacks a cryptographically signed digital watermark or uses an unauthenticated signature algorithm, preventing physical DNA origin attribution.', | |
| evidence: `Watermark missing: ${watermarkMissing}, Unsigned signature: ${signatureMissing}`, | |
| impact: | |
| 'Disables traceability of synthetic gene constructs back to the originating foundry in the event of biocontainment escape or misuse.', | |
| remediation: | |
| 'Inject cryptographically signed in-silico and in-vitro Ed25519 digital watermarks into all synthetic constructs.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Mandate Ed25519 cryptographically signed digital watermarking on all synthesized oligonucleotides.' | |
| }); | |
| } | |
| } | |
| // 3. VF-DNAMICRO-003 (CRITICAL, CWE-353): Customer Identity & Legitimate End-User Screening Attestation Failure | |
| if (enforceKyc) { | |
| const kycMissing = | |
| /("enforceInstitutionalKyc"\s*:\s*false|"kyc_verified"\s*:\s*false|institutional_verification\s*[:=]\s*false)/i.test( | |
| content | |
| ) || | |
| (parsedJson?.customerKycAttestation?.enforceInstitutionalKyc === false) || | |
| (parsedJson?.kyc_verified === false) || | |
| (parsedJson?.customer_identity?.verified === false); | |
| const bslMissing = | |
| /("requireBslVerification"\s*:\s*false|bsl_containment_level\s*[:=]\s*"none")/i.test(content) || | |
| (parsedJson?.customerKycAttestation?.requireBslVerification === false); | |
| if (kycMissing || bslMissing) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-003', | |
| findingCode: 'VF-DNAMICRO-003', | |
| title: 'Customer Identity & Legitimate End-User Screening Attestation Failure (Know-Your-Customer / KYC)', | |
| severity: 'CRITICAL', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-353', | |
| target: filePath, | |
| description: | |
| 'DNA synthesis order lacks verified institutional customer identity or valid biosafety containment (BSL-3/BSL-4) accreditation credentials.', | |
| evidence: `Institutional KYC missing: ${kycMissing}, BSL containment verification missing: ${bslMissing}`, | |
| impact: | |
| 'Allows unvetted or fictitious entities to procure restricted gene fragments without institutional oversight.', | |
| remediation: | |
| 'Enforce strict institutional Know-Your-Customer validation and accredited biosafety containment certification prior to order clearance.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Enforce institutional KYC attestation and valid BSL facility credential verification.' | |
| }); | |
| } | |
| } | |
| // 4. VF-DNAMICRO-004 (HIGH, CWE-284): Dual-Use Research of Concern (DURC) Gene Perturbation & Virulence Enhancer Masking | |
| if (enforceDurc) { | |
| const durcSplitDetected = | |
| /("enforceMultiFragmentAssemblyCheck"\s*:\s*false|"split_synthesis_assembly_check"\s*:\s*false)/i.test( | |
| content | |
| ) || | |
| (parsedJson?.durcSplitSynthesisDefense?.enforceMultiFragmentAssemblyCheck === false) || | |
| (parsedJson?.split_gene_orders_detected === true && parsedJson?.assembly_verified === false) || | |
| (parsedJson?.multi_fragment_assembly === true && (parsedJson?.split_gene_coverage_pct || 0) > 15.0); | |
| const coverageMatch = content.match(/(?:maxCumulativePathogenCoveragePct|pathogen_coverage_pct|split_gene_coverage_pct)"?\s*[:=]\s*([0-9.]+)/i); | |
| const excessiveCoverage = | |
| (coverageMatch && Number(coverageMatch[1]) > 15.0) || | |
| (parsedJson?.durcSplitSynthesisDefense?.maxCumulativePathogenCoveragePct !== undefined && | |
| Number(parsedJson.durcSplitSynthesisDefense.maxCumulativePathogenCoveragePct) > 15.0) || | |
| (parsedJson?.split_gene_coverage_pct !== undefined && Number(parsedJson.split_gene_coverage_pct) > 15.0); | |
| if (durcSplitDetected || excessiveCoverage) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-004', | |
| findingCode: 'VF-DNAMICRO-004', | |
| title: 'Dual-Use Research of Concern (DURC) Gene Perturbation & Virulence Enhancer Masking', | |
| severity: 'HIGH', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-284', | |
| target: filePath, | |
| description: | |
| 'Detected split-gene synthesis fragments designed to assemble into a regulated virulence factor or toxin without cross-order assembly reconstruction screening.', | |
| evidence: `Multi-fragment check disabled: ${durcSplitDetected}, Excessive pathogen coverage: ${excessiveCoverage}`, | |
| impact: | |
| 'Adversaries can circumvent single-oligo homology filters by partitioning regulated toxins across multiple non-regulated synthesis batches.', | |
| remediation: | |
| 'Activate multi-fragment sequence assembly analysis and enforce maximum 15.0% cumulative coverage bounds.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Mandate multi-fragment DURC assembly reconstruction checks across customer order history.' | |
| }); | |
| } | |
| } | |
| // 5. VF-DNAMICRO-005 (HIGH, CWE-400): Microarray Hybridization Spot Density Over-Saturation & Optical Fluorophore Bleed | |
| if (enforceSpotDensity) { | |
| const densityMatch = content.match(/(?:probe_spot_density_pct|microarray_spot_density_pct|spot_density_pct)"?\s*[:=]\s*([0-9.]+)/i); | |
| const spotDensityOver = | |
| /("enforceSpotDensityLimits"\s*:\s*false)/i.test(content) || | |
| (densityMatch && Number(densityMatch[1]) > 90.0) || | |
| (parsedJson?.microarrayDensityCrosstalk?.enforceSpotDensityLimits === false) || | |
| (parsedJson?.microarray_spot_density_pct !== undefined && Number(parsedJson.microarray_spot_density_pct) > 90.0) || | |
| (parsedJson?.spot_density_pct !== undefined && Number(parsedJson.spot_density_pct) > 90.0); | |
| const crosstalkMatch = content.match(/(?:fluorophore_crosstalk_pct|crosstalk_bleed)"?\s*[:=]\s*([0-9.]+)/i); | |
| const fluorophoreBleed = | |
| (crosstalkMatch && Number(crosstalkMatch[1]) > 3.0) || | |
| (parsedJson?.microarrayDensityCrosstalk?.maxFluorophoreCrosstalkPct !== undefined && | |
| Number(parsedJson.microarrayDensityCrosstalk.maxFluorophoreCrosstalkPct) > 3.0) || | |
| (parsedJson?.fluorophore_crosstalk_pct !== undefined && Number(parsedJson.fluorophore_crosstalk_pct) > 3.0); | |
| if (spotDensityOver || fluorophoreBleed) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-005', | |
| findingCode: 'VF-DNAMICRO-005', | |
| title: 'Microarray Hybridization Spot Density Over-Saturation & Optical Fluorophore Bleed', | |
| severity: 'HIGH', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-400', | |
| target: filePath, | |
| description: | |
| 'Microarray hybridization probe density exceeds 90% or optical Cy3/Cy5 fluorophore crosstalk exceeds 3.0%, causing diagnostic signal saturation and masking bio-pathogen markers.', | |
| evidence: `Spot density violation: ${spotDensityOver}, Fluorophore crosstalk: ${fluorophoreBleed}`, | |
| impact: | |
| 'Sensor saturation produces false-negative diagnostics, blinding automated biosecurity monitoring arrays to regulated sequence signatures.', | |
| remediation: | |
| 'Clamp probe spot density to <= 90% and calibrate optical bandpass filters to limit fluorophore crosstalk to <= 3.0%.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Clamp microarray probe spot density to <= 90% and suppress optical crosstalk <= 3.0%.' | |
| }); | |
| } | |
| } | |
| // 6. VF-DNAMICRO-006 (HIGH, CWE-208): Ephemeral Codon Optimization Evasion & Homology Scrambling Side-Channel | |
| if (enforceCodon) { | |
| const codonEvasion = | |
| /("enforceAminoAcidHomologyScreening"\s*:\s*false|"synonymous_evasion_detected"\s*:\s*true|"codon_scrambling_detected"\s*:\s*true|"six_frame_translation_audit"\s*:\s*false|amino_acid_translation\s*[:=]\s*false)/i.test( | |
| content | |
| ) || | |
| (parsedJson?.codonScramblingDetection?.enforceAminoAcidHomologyScreening === false) || | |
| (parsedJson?.synonymous_evasion_detected === true) || | |
| (parsedJson?.codon_scrambling_detected === true) || | |
| (parsedJson?.six_frame_translation_audit === false); | |
| if (codonEvasion) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-006', | |
| findingCode: 'VF-DNAMICRO-006', | |
| title: 'Ephemeral Codon Optimization Evasion & Homology Scrambling Side-Channel', | |
| severity: 'HIGH', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-208', | |
| target: filePath, | |
| description: | |
| 'Synonymous codon substitution was detected that evades nucleotide-level BLAST pattern matching while expressing identical regulated toxic protein sequences.', | |
| evidence: `Synonymous codon evasion detected or amino acid homology translation disabled: ${codonEvasion}`, | |
| impact: | |
| 'Enables synthesis of functional toxin proteins through heavily mutated nucleotide sequences that evade simple string-matching filters.', | |
| remediation: | |
| 'Mandate six-frame amino acid translation and protein structural homology alignment during biosecurity screening.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Enforce six-frame protein translation screening to neutralize synonymous codon evasion.' | |
| }); | |
| } | |
| } | |
| // 7. VF-DNAMICRO-007 (HIGH, CWE-294): Synthesis Nonce Replay & Stale Biosecurity Certificate Re-Use | |
| if (enforceNonce) { | |
| const ageMatch = content.match(/(?:synthesis_nonce_age_seconds|certificate_age_seconds)"?\s*[:=]\s*([0-9]+)/i); | |
| const nonceStale = | |
| /("enforceFreshSynthesisNonces"\s*:\s*false|"nonce_replayed"\s*:\s*true|"stale_nonce_detected"\s*:\s*true|stale_certificate\s*[:=]\s*true)/i.test( | |
| content | |
| ) || | |
| (parsedJson?.synthesisNonceLifecycle?.enforceFreshSynthesisNonces === false) || | |
| (parsedJson?.nonce_replayed === true) || | |
| (parsedJson?.stale_nonce_detected === true) || | |
| (ageMatch && Number(ageMatch[1]) > 86400) || | |
| (Number(parsedJson?.synthesis_nonce_age_seconds || parsedJson?.certificate_age_seconds || 0) > 86400); | |
| if (nonceStale) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-007', | |
| findingCode: 'VF-DNAMICRO-007', | |
| title: 'Synthesis Nonce Replay & Stale Biosecurity Certificate Re-Use', | |
| severity: 'HIGH', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-294', | |
| target: filePath, | |
| description: | |
| 'Synthesis authorization nonce is replayed or biosecurity clearance certificate has exceeded the maximum 86400s validity window.', | |
| evidence: `Synthesis nonce replay or expired biosecurity certificate detected: ${nonceStale}`, | |
| impact: | |
| 'Allows an adversary to repeatedly execute unauthorized synthesis jobs using previously approved single-use clearance tokens.', | |
| remediation: | |
| 'Enforce single-use cryptographic synthesis nonces and invalidate biosecurity certificates older than 24 hours.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Enforce single-use monotonic synthesis nonces and expire biosecurity certificates <= 86400s.' | |
| }); | |
| } | |
| } | |
| // 8. VF-DNAMICRO-008 (HIGH, CWE-754): Synthesis Equipment Fail-Open Posture & Physical Gene Foundry Tamper Lockdown Failure | |
| if (enforceFailClosed) { | |
| const failOpenDetected = | |
| /("enforceFailClosedSynthesisAbort"\s*:\s*false|"fail_open_on_timeout"\s*:\s*true|abort_on_disconnect\s*[:=]\s*false)/i.test( | |
| content | |
| ) || | |
| (parsedJson?.equipmentFailClosed?.enforceFailClosedSynthesisAbort === false) || | |
| (parsedJson?.fail_open_on_timeout === true) || | |
| (Number(parsedJson?.lockdown_response_ms || 0) > 500); | |
| if (failOpenDetected) { | |
| findings.push({ | |
| id: 'VF-DNAMICRO-008', | |
| findingCode: 'VF-DNAMICRO-008', | |
| title: 'Synthesis Equipment Fail-Open Posture & Physical Gene Foundry Tamper Lockdown Failure', | |
| severity: 'HIGH', | |
| category: 'dna_microarray_biosecurity', | |
| cwe: 'CWE-754', | |
| target: filePath, | |
| description: | |
| 'Synthesizer hardware fails open upon screening pipeline timeout or network disconnect, allowing chemical coupling cycles to complete without positive clearance.', | |
| evidence: `Equipment fail-open or slow emergency lockdown detected: ${failOpenDetected}`, | |
| impact: | |
| 'Physical gene synthesis machinery continues printing hazardous oligonucleotides when network screening links are severed.', | |
| remediation: | |
| 'Configure fail-closed hardware interlocks with automatic chemical reagent purging and sub-500ms emergency lockdown response.' | |
| }); | |
| patchRecommendations.push({ | |
| patchType: 'dna_microarray_hardening', | |
| targetFile: filePath, | |
| description: 'Configure fail-closed hardware synthesis interlocks with automatic chemical purge.' | |
| }); | |
| } | |
| } | |
| const criticalCount = findings.filter(f => f.severity === 'CRITICAL').length; | |
| const highCount = findings.filter(f => f.severity === 'HIGH').length; | |
| const mediumCount = findings.filter(f => f.severity === 'MEDIUM').length; | |
| const lowCount = findings.filter(f => f.severity === 'LOW').length; | |
| const totalChecks = 8; | |
| const findingsCount = findings.length; | |
| const passedChecks = Math.max(0, totalChecks - findingsCount); | |
| let score = Math.max(0, 100 - criticalCount * 25 - highCount * 12 - mediumCount * 5 - lowCount * 2); | |
| const complianceStatus: 'PASS' | 'WARN' | 'FAIL' = | |
| criticalCount > 0 ? 'FAIL' : highCount > 0 ? 'WARN' : 'PASS'; | |
| const passed = criticalCount === 0 && highCount === 0; | |
| const summary: DnaMicroarrayAuditSummary = { | |
| score, | |
| totalChecks, | |
| passedChecks, | |
| findingsCount, | |
| severityCounts: { critical: criticalCount, high: highCount, medium: mediumCount, low: lowCount }, | |
| format, | |
| complianceStatus, | |
| passed, | |
| pathogenScreeningEnforced: !findings.some(f => f.id === 'VF-DNAMICRO-001'), | |
| digitalWatermarkVerified: !findings.some(f => f.id === 'VF-DNAMICRO-002'), | |
| customerKycAttested: !findings.some(f => f.id === 'VF-DNAMICRO-003'), | |
| durcAssemblyChecked: !findings.some(f => f.id === 'VF-DNAMICRO-004'), | |
| spotDensityConstrained: !findings.some(f => f.id === 'VF-DNAMICRO-005'), | |
| codonScramblingNeutralized: !findings.some(f => f.id === 'VF-DNAMICRO-006'), | |
| synthesisNoncesSynchronized: !findings.some(f => f.id === 'VF-DNAMICRO-007'), | |
| equipmentFailClosedEngaged: !findings.some(f => f.id === 'VF-DNAMICRO-008') | |
| }; | |
| const recommendedPolicy = synthesizeDnaMicroarrayPolicy(filePath, findings); | |
| return { | |
| targetFile: filePath, | |
| findings, | |
| summary, | |
| recommendedPolicy, | |
| patchRecommendations, | |
| passed, | |
| complianceStatus, | |
| attestationStatus: passed ? 'VERIFIED_SECURE' : 'ATTESTATION_FAILED' | |
| }; | |
| } | |
| export function generateDnaMicroarrayFuzzCases(): FuzzMutationCase[] { | |
| return [ | |
| { | |
| id: 'fuzz-dnamicro-001-pathogen-screening', | |
| field: 'pathogenHomologyScreening.enforceSelectAgentScreening', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'Disabled pathogen screening flag with truncated homology window (50 bp)', | |
| payload: JSON.stringify({ | |
| pathogenHomologyScreening: { | |
| enforceSelectAgentScreening: false, | |
| minScreeningWindowBp: 50, | |
| maxEvalueThreshold: 1.0 | |
| } | |
| }), | |
| expectedStatus: 400 | |
| }, | |
| { | |
| id: 'fuzz-dnamicro-002-digital-watermark', | |
| field: 'digitalWatermarkProvenance.enforceDigitalWatermarking', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'Omission of Ed25519 digital watermark payload signature', | |
| payload: JSON.stringify({ | |
| digitalWatermarkProvenance: { | |
| enforceDigitalWatermarking: false, | |
| requireEd25519WatermarkSignature: false | |
| } | |
| }), | |
| expectedStatus: 400 | |
| }, | |
| { | |
| id: 'fuzz-dnamicro-003-customer-kyc', | |
| field: 'customerKycAttestation.enforceInstitutionalKyc', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'Customer KYC screening bypass with unverified institutional recipient', | |
| payload: JSON.stringify({ | |
| customerKycAttestation: { | |
| enforceInstitutionalKyc: false, | |
| requireBslVerification: false | |
| } | |
| }), | |
| expectedStatus: 400 | |
| }, | |
| { | |
| id: 'fuzz-dnamicro-004-durc-split', | |
| field: 'durcSplitSynthesisDefense.enforceMultiFragmentAssemblyCheck', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'DURC split gene fragments with excessive pathogen coverage (45%)', | |
| payload: JSON.stringify({ | |
| durcSplitSynthesisDefense: { | |
| enforceMultiFragmentAssemblyCheck: false | |
| }, | |
| pathogen_coverage_pct: 45.0 | |
| }), | |
| expectedStatus: 400 | |
| }, | |
| { | |
| id: 'fuzz-dnamicro-005-spot-density', | |
| field: 'microarrayDensityCrosstalk.maxProbeSpotDensityPct', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'Microarray probe spot density saturation (98%) and 12% optical fluorophore bleed', | |
| payload: JSON.stringify({ | |
| probe_spot_density_pct: 98.0, | |
| fluorophore_crosstalk_pct: 12.0 | |
| }), | |
| expectedStatus: 400 | |
| }, | |
| { | |
| id: 'fuzz-dnamicro-006-codon-scrambling', | |
| field: 'codonScramblingDetection.enforceAminoAcidHomologyScreening', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'Synonymous codon optimization scrambling without protein translation check', | |
| payload: JSON.stringify({ | |
| synonymous_evasion_detected: true, | |
| codonScramblingDetection: { | |
| enforceAminoAcidHomologyScreening: false | |
| } | |
| }), | |
| expectedStatus: 400 | |
| }, | |
| { | |
| id: 'fuzz-dnamicro-007-nonce-replay', | |
| field: 'synthesisNonceLifecycle.enforceFreshSynthesisNonces', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'Stale synthesis nonce replay exceeding 86400s threshold', | |
| payload: JSON.stringify({ | |
| nonce_replayed: true, | |
| synthesis_nonce_age_seconds: 180000 | |
| }), | |
| expectedStatus: 400 | |
| }, | |
| { | |
| id: 'fuzz-dnamicro-008-fail-closed', | |
| field: 'equipmentFailClosed.enforceFailClosedSynthesisAbort', | |
| mutationType: 'BOUNDARY_INT', | |
| description: 'Synthesizer hardware fail-open on network timeout with slow lockdown (>1200ms)', | |
| payload: JSON.stringify({ | |
| fail_open_on_timeout: true, | |
| lockdown_response_ms: 1200 | |
| }), | |
| expectedStatus: 400 | |
| } | |
| ]; | |
| } | |