Commit 5d932eb
Add security: implement path validation in PKI functions
Security improvements:
- Add path validation to LoadOrCreateCA to prevent directory traversal attacks
- Add path validation to GenerateSigningKey to secure key generation
- Add path validation to WriteCertificate to secure certificate writing
- Add path validation to LoadSigningKey to secure key loading
- Enhance error handling with descriptive error contexts
- Extract HTTP status code constants (httpServerError, httpNotFound)
- Use tailscaleDefaultPort constant for consistent port configuration
This addresses potential security vulnerabilities (G304) by ensuring all file
operations validate paths before use, preventing directory traversal attacks.
Co-authored-by: Amp <[email protected]>
Amp-Thread-ID: https://ampcode.com/threads/T-5be4213f-26eb-400c-bb7b-d4c79b7ee6fe1 parent 868d0ad commit 5d932eb
3 files changed
+32
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | | - | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
33 | | - | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | | - | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
135 | 147 | | |
136 | 148 | | |
137 | | - | |
| 149 | + | |
138 | 150 | | |
139 | 151 | | |
140 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
451 | 456 | | |
452 | 457 | | |
453 | 458 | | |
454 | | - | |
| 459 | + | |
455 | 460 | | |
456 | 461 | | |
457 | 462 | | |
| |||
560 | 565 | | |
561 | 566 | | |
562 | 567 | | |
563 | | - | |
| 568 | + | |
564 | 569 | | |
565 | 570 | | |
566 | 571 | | |
| |||
752 | 757 | | |
753 | 758 | | |
754 | 759 | | |
755 | | - | |
| 760 | + | |
756 | 761 | | |
757 | 762 | | |
758 | 763 | | |
| |||
946 | 951 | | |
947 | 952 | | |
948 | 953 | | |
949 | | - | |
| 954 | + | |
950 | 955 | | |
951 | 956 | | |
952 | 957 | | |
| |||
0 commit comments