Fossil SCM

only allow a certain whitelist of characters for linked tags and hashes to guard against injection

jkosche 2025-04-12 16:31 tkt-improvements
Commit 70b2569ec0a0ee89cc4f67d43c99c07a4182b2b40c16c5ef6cbba02d02f1abaa
1 file changed +12 -6
+12 -6
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -521,17 +521,23 @@
521521
@ <tr><td class="tktDspLabel">Version&nbsp;Found&nbsp;In:</td>
522522
@ <td colspan="3" valign="top" class="tktDspValue">
523523
@ <th1>
524524
@ set versionlink ""
525525
@ set urlfoundin [httpize $foundin]
526
-@ query {SELECT count(*) AS match FROM tag
527
-@ WHERE tagname=concat('sym-',$foundin)} {
528
-@ if {$match} {set versionlink "/timeline?t=$urlfoundin"}
526
+@ set tagpattern ^\[0-9A-Za-z_\\.\]+\$
527
+@ if [regexp $tagpattern $foundin] {
528
+@ query {SELECT count(*) AS match FROM tag
529
+@ WHERE tagname=concat('sym-',$foundin)} {
530
+@ if {$match} {set versionlink "/timeline?t=$urlfoundin"}
531
+@ }
529532
@ }
530
-@ set pattern $foundin%
531
-@ query {SELECT count(*) AS match FROM blob WHERE uuid GLOB $pattern} {
532
-@ if {$match} {set versionlink "/info/$urlfoundin"}
533
+@ set hashpattern ^\[0-9a-f\]+\$
534
+@ if [regexp $hashpattern $foundin] {
535
+@ set pattern $foundin*
536
+@ query {SELECT count(*) AS match FROM blob WHERE uuid GLOB $pattern} {
537
+@ if {$match} {set versionlink "/info/$urlfoundin"}
538
+@ }
533539
@ }
534540
@ if {$versionlink eq ""} {
535541
@ puts $foundin
536542
@ } else {
537543
@ html "<a href=\"$versionlink\">"
538544
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -521,17 +521,23 @@
521 @ <tr><td class="tktDspLabel">Version&nbsp;Found&nbsp;In:</td>
522 @ <td colspan="3" valign="top" class="tktDspValue">
523 @ <th1>
524 @ set versionlink ""
525 @ set urlfoundin [httpize $foundin]
526 @ query {SELECT count(*) AS match FROM tag
527 @ WHERE tagname=concat('sym-',$foundin)} {
528 @ if {$match} {set versionlink "/timeline?t=$urlfoundin"}
 
 
 
529 @ }
530 @ set pattern $foundin%
531 @ query {SELECT count(*) AS match FROM blob WHERE uuid GLOB $pattern} {
532 @ if {$match} {set versionlink "/info/$urlfoundin"}
 
 
 
533 @ }
534 @ if {$versionlink eq ""} {
535 @ puts $foundin
536 @ } else {
537 @ html "<a href=\"$versionlink\">"
538
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -521,17 +521,23 @@
521 @ <tr><td class="tktDspLabel">Version&nbsp;Found&nbsp;In:</td>
522 @ <td colspan="3" valign="top" class="tktDspValue">
523 @ <th1>
524 @ set versionlink ""
525 @ set urlfoundin [httpize $foundin]
526 @ set tagpattern ^\[0-9A-Za-z_\\.\]+\$
527 @ if [regexp $tagpattern $foundin] {
528 @ query {SELECT count(*) AS match FROM tag
529 @ WHERE tagname=concat('sym-',$foundin)} {
530 @ if {$match} {set versionlink "/timeline?t=$urlfoundin"}
531 @ }
532 @ }
533 @ set hashpattern ^\[0-9a-f\]+\$
534 @ if [regexp $hashpattern $foundin] {
535 @ set pattern $foundin*
536 @ query {SELECT count(*) AS match FROM blob WHERE uuid GLOB $pattern} {
537 @ if {$match} {set versionlink "/info/$urlfoundin"}
538 @ }
539 @ }
540 @ if {$versionlink eq ""} {
541 @ puts $foundin
542 @ } else {
543 @ html "<a href=\"$versionlink\">"
544

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button