other
- Location
pharmgx_reporter.py:785- Finding
Missing or Unsupported Genetic Data Silently Produces Normal Phenotypes and Standard-Dose Recommendations
- Content
View full analysis
Vulnerability Details
File Location:
pharmgx_reporter.py:785-910
Vulnerability Type: Fail-open medical inference and result-integrity failure
Risk Level: HighVulnerable Code
python def call_diplotype(gene, pgx_snps): gdef = GENE_DEFS[gene] if gdef.get("type") == "genotype": rsid = gdef["rsid"] if rsid in pgx_snps: return pgx_snps[rsid]["genotype"] return gdef["ref"] + gdef["ref"] detected = [] for rsid, vdef in gdef["variants"].items(): if rsid in pgx_snps: gt = pgx_snps[rsid]["genotype"] alt = vdef["alt"].upper() alt_count = gt.count(alt) if alt != "DEL" and alt != "INS" and alt != "TA7" else 0 if alt_count > 0: detected.append({"rsid": rsid, "allele": vdef["allele"], "copies": alt_count, "effect": vdef["effect"]}) if gdef.get("type") == "dpyd": if not detected: return "Normal/Normal" v = detected[0] if v["copies"] == 2: return f"{v['allele']}/{v['allele']}" return f"Normal/{v['allele']}" if not detected: return f"{gdef['ref']}/{gdef['ref']}"python def call_phenotype(gene, diplotype): gdef = GENE_DEFS[gene] norm = diplotype.upper() for desc, conditions in gdef["phenotypes"].items(): for cond in conditions: if norm == cond.upper(): return desc parts = cond.split("/") if len(parts) == 2 and norm == f"{parts[1]}/{parts[0]}".upper(): return desc return "Normal (inferred)"python def phenotype_to_key(phenotype_desc): """Map phenotype description to GUIDELINES rec key.""" mapping = { "Normal Metabolizer": "normal_metabolizer", "Intermediate Metabolizer": "intermediate_metabolizer", ...[truncated 3878 chars]- Remediation
View remediation
Remediation Suggestions
- Introduce explicit states such as
Unknown,Not tested,Insufficient coverage, andUnsupported diplotype. - Track expected and observed SNP coverage independently for every gene.
- Infer a reference allele only when the relevant loci have valid reference genotype calls; never infer it merely because a record is absent.
- Return
Unknownrather thanNormal (inferred)when a diplotype is not present in the phenotype mapping. - Remove the default
normal_metabolizerfallback fromphenotype_to_key(). ReturnNoneor raise a controlled validation error for unknown values. - Do not generate medication recommendations for genes with insufficient coverage or unsupported phenotypes.
- Replace the standard-dose fallback in
lookup_drugs()with an explicit “No recommendation available” classification. - Add prominent per-gene coverage and confidence fields to the report.
- Reject wholly unknown formats and files that do not meet a documented minimum coverage threshold.
- Add negative tests for empty files, partial files, malformed genotype calls, unsupported diplotypes, and missing recommendation keys.
- Introduce explicit states such as
