Skip to content

Commit

Permalink
improve session check security by just searching for sid=@xxx@
Browse files Browse the repository at this point in the history
  • Loading branch information
jens-maus committed Dec 13, 2022
1 parent 94651d0 commit a94dc0b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5
2.6
11 changes: 0 additions & 11 deletions www/exec.cgi
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/bin/tclsh

load tclrega.so
source session.tcl

catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
set $varname $val
}
}
}

proc toString { str } {
set map {
"\"" "\\\""
Expand Down
11 changes: 0 additions & 11 deletions www/exec1.cgi
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/bin/tclsh

load tclrega.so
source session.tcl

catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
set $varname $val
}
}
}

proc toString { str } {
set map {
"\"" "\\\""
Expand Down
14 changes: 13 additions & 1 deletion www/session.tcl
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

load tclrega.so

catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
set sid ""
foreach pair $pairs {
if {0 != [regexp "^sid=(@.*@)$" $pair dummy val]} {
set sid $val
break
}
}
}

proc check_session sid {
if {[regexp {@([0-9a-zA-Z]{10})@} $sid all sidnr]} {
set res [lindex [rega_script "Write(system.GetSessionVarStr('$sidnr'));"] 1]
Expand All @@ -10,4 +22,4 @@ proc check_session sid {
}
}
return 0
}
}

0 comments on commit a94dc0b

Please sign in to comment.