History

don't expose secstore secrets in /mnt/term/dev/secstore

this feature is too dangerous. i can imagine it being there so a server side factotum can use the drawterms secstore keys that it already loaded, but this makes it just too easy to steal the keys. now we zero the secstorebuf after we extracted the plan9 key from it so no secrets are left behind in drawterms memory after authentication is done.

cinap_lenrek committed 10 years ago

Commit 39347ab1 parent 162ce8d3 files · +3 −21Browse files

Unified · Split

3 files
  1. cpu.c +2 −0
  2. kern/devcons.c +0 −21
  3. main.c +1 −0
cpu.c+2−0
@@ -637,6 +637,8 @@ p9any(int fd) · 636 unmodified lines
637637
638638 u = user;
639639 pass = findkey(&u, tr.authdom, proto);
640+ memset(secstorebuf, 0, sizeof(secstorebuf)); /* forget secstore secrets */
641+
640642 if(pass == nil)
641643 again:
642644 pass = getkey(u, tr.authdom, proto);
kern/devcons.c+0−21
@@ -464,7 +464,6 @@ enum{ · 463 unmodified lines
464464 Qppid,
465465 Qrandom,
466466 Qreboot,
467− Qsecstore,
468467 Qshowfile,
469468 Qsnarf,
470469 Qswap,
@@ -498,7 +497,6 @@ static Dirtab consdir[]={ · 27 unmodified lines
498497 "ppid", {Qppid}, NUMSIZE, 0444,
499498 "random", {Qrandom}, 0, 0444,
500499 "reboot", {Qreboot}, 0, 0664,
501− "secstore", {Qsecstore}, 0, 0666,
502500 "showfile", {Qshowfile}, 0, 0220,
503501 "snarf", {Qsnarf}, 0, 0666,
504502 "swap", {Qswap}, 0, 0664,
@@ -509,8 +507,6 @@ static Dirtab consdir[]={ · 4 unmodified lines
509507 "zero", {Qzero}, 0, 0444,
510508 };
511509
512−char secstorebuf[65536];
513−Dirtab *secstoretab = &consdir[Qsecstore];
514510 Dirtab *snarftab = &consdir[Qsnarf];
515511
516512 int
@@ -605,13 +601,6 @@ consopen(Chan *c, int omode) · 88 unmodified lines
605601 c->iounit = qiomaxatomic;
606602 break;
607603
608− case Qsecstore:
609− if(omode == ORDWR)
610− error(Eperm);
611− if(omode != OREAD)
612− memset(secstorebuf, 0, sizeof secstorebuf);
613− break;
614−
615604 case Qsnarf:
616605 if(omode == ORDWR)
617606 error(Eperm);
@@ -765,9 +754,6 @@ consread(Chan *c, void *buf, long n, vlong off) · 147 unmodified lines
765754 return 0;
766755 return readstr(offset, buf, n, c->aux);
767756
768− case Qsecstore:
769− return readstr(offset, buf, n, secstorebuf);
770−
771757 case Qsysstat:
772758 return 0;
773759
@@ -915,13 +901,6 @@ conswrite(Chan *c, void *va, long n, vlong off) · 141 unmodified lines
915901 free(cb);
916902 break;
917903
918− case Qsecstore:
919− if(offset >= sizeof secstorebuf || offset+n+1 >= sizeof secstorebuf)
920− error(Etoobig);
921− secstoretab->qid.vers++;
922− memmove(secstorebuf+offset, va, n);
923− return n;
924−
925904 case Qshowfile:
926905 return showfilewrite(a, n);
927906
main.c+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88
99 char *argv0;
1010 char *user;
11+char secstorebuf[65536];
1112
1213 extern int errfmt(Fmt*);
1314 void

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t