-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taint support #203
base: master
Are you sure you want to change the base?
Taint support #203
Conversation
======================== | ||
|
||
Author: Steve Bennett <steveb@workware.net.au> | ||
Date: 24 May 2011 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this really planned 10 years ago?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, really. Been out of tree for that long. I thought it was time to share.
Thanks for your edits below. I'll integrate them.
Perl and Ruby support the concept of tainted data, taint sources | ||
and taint sinks. The idea is to improve security in situations | ||
where data may be coming from outside the program (e.g. input | ||
to a web application) should not inadvertently be output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to a web application) should not inadvertently be output | |
to a web application). This data should not inadvertently be output |
(to avoid SQL injections attacks) or to execute system commands | ||
(to avoid system attacks). | ||
|
||
Standard Tcl does not support tainting. Instead it uses "safe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standard Tcl does not support tainting. Instead it uses "safe" | |
Standard Tcl does not support tainting, but uses "safe" |
While the tainted value can be distinguished from other values | ||
in the container, the container is not tainted. However if the container | ||
needs to change representation (the entire container becomes tainted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the tainted value can be distinguished from other values | |
in the container, the container is not tainted. However if the container | |
needs to change representation (the entire container becomes tainted. | |
If the tainted value can be distinguished from other values | |
in the container, the container is not tainted. However, if the container | |
needs to change representation, the entire container becomes tainted. |
Taint types | ||
----------- | ||
It may be useful to distinguish between different types of taint. | ||
Each taint type is associate with a bit field. The standard taint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each taint type is associate with a bit field. The standard taint | |
Each taint type is assigned a bit in a taint bit field. The standard taint |
|
||
More Information | ||
---------------- | ||
In order to simplify taint propagation, the interpreter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to simplify taint propagation, the interpreter | |
To simplify taint propagation, the interpreter |
|
||
The Rules | ||
--------- | ||
- The taint and untaint commands operate on variables and taint/untaint the contents of the variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The taint and untaint commands operate on variables and taint/untaint the contents of the variable | |
- The taint and untaint commands operate on variables, and taint/untaint the contents of the variable |
The Rules | ||
--------- | ||
- The taint and untaint commands operate on variables and taint/untaint the contents of the variable | ||
- Adding/modifying a list/dict/array element taints that element plus the "container" but not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Adding/modifying a list/dict/array element taints that element plus the "container" but not | |
- Adding/modifying a list/dict/array element taints that element plus the "container", but not |
Specific Notes | ||
-------------- | ||
In general, a conservative approach is used to tainting, so if | ||
a command creates a new object while any of it's arguments are tainted, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a command creates a new object while any of it's arguments are tainted, | |
a command creates a new object while any of its arguments are tainted, |
a command creates a new object while any of it's arguments are tainted, | ||
the new object is also tainted. | ||
|
||
However the list-related commands are more intelligent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However the list-related commands are more intelligent. | |
However, the list-related commands are more intelligent. |
|
||
However the list-related commands are more intelligent. | ||
All list-related commands such as lindex, lrange, lassign and lreplace will | ||
maintain the taint of existing list elements, but will avoid tainting untainted elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maintain the taint of existing list elements, but will avoid tainting untainted elements. | |
not change the taint of existing list elements. |
I have only played with this feature in the REPL so far, but I can see it being useful. Some feedback:
|
Thanks. All feedback is useful. I am hesitant about adding new error codes, but I'll consider yet. |
You're welcome!
Why? I understand that there is no central accounting for
Ah, good. |
I have a feature request: check for tainted data in the Redis extension, too, and in |
Yes, for sure with Win32_ShellExecute. Not so sure about the redis extension, as there is no quoting in args passed to redis, it is hard to get an injection attack. We could check for taint in the command (first arg) to redis, as that certainly shouldn't come from outside the system, but this seems like a low risk. Regarding |
Great! \o/
There is also the command
Ah, I see. I'd set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Welcome to Jim version 0.80
. source jimlib.tcl
. set a 5
5
. taint a
. lib::try { exec echo $a } trap TAINTED {x y} { list $x $y }
{exec: tainted data} {-code 1 -level 0 -errorinfo {} -errorcode TAINTED}
Thanks. Will merge once I've updated the documentation. |
@@ -0,0 +1,143 @@ | |||
Taint Suport for Jim Tcl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taint Suport for Jim Tcl | |
Taint Support for Jim Tcl |
Thanks. Now that 0.82 is released I plan to get this into the next release |
See README.taint Signed-off-by: Steve Bennett <steveb@workware.net.au>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Compile tested only. Signed-off-by: Steve Bennett <steveb@workware.net.au>
FYI, I plan to merge this as part of https://github.com/msteveb/jimtcl/tree/cmd-register in the coming weeks |
See README.taint for details