emission-graph-computed-elem-write-key-taint.ts 856 B

123456789101112131415
  1. // A facade ask in the KEY position of an element-access WRITE (`o[<ask>] = v`). Runtime: ask#2's
  2. // output becomes a KEY of `o`, so a later `for (const k in o)` enumerates that tainted key string
  3. // ("strings launder nothing"). Required may-flow: ask#1 -> ask#2 (s into the write-key
  4. // instructions) and ask#2 -> ask#3 (the key string, via the for-in accumulator, into ask#3's
  5. // instructions). If the write key is skipped, ask#2 loses its sinks AND `o` never carries the
  6. // key taint, so the for-in read drops the edge — which would also make the for-in fix unsound
  7. // against computed writes.
  8. const s = await agent("keeper").ask<string>("secret");
  9. const o: Record<string, number> = {};
  10. o[await agent("namer").ask<string>(`name using ${s}`)] = 1;
  11. let keys = "";
  12. for (const k in o) {
  13. keys += k;
  14. }
  15. return agent("final").ask<string>(`fields ${keys}`);