class-field-method.ts 586 B

1234567891011121314151617
  1. // A class instance carries taint through a constructor-stored field returned by a
  2. // method. Sound today at whole-object granularity: the ask result flows into `new`,
  3. // the instance carries it, and box.get() returns it into the reader ask.
  4. // Expected: source -> ask#1, ask#1 -> ask#2, ask#2 -> sink.
  5. class Box {
  6. x: string;
  7. constructor(v: string) {
  8. this.x = v;
  9. }
  10. get(): string {
  11. return this.x;
  12. }
  13. }
  14. const secret = await agent("writer").ask<string>("secret");
  15. const box = new Box(secret);
  16. const out = await agent("reader").ask<string>(`use ${box.get()}`);
  17. return out;