On Wed, Jun 6, 2012 at 3:57 PM, <
sqrt...@googlemail.com> wrote:
> Hi Toon,
>
> I greatly appreciate the input - that helped me, thank you.
>
> The basic idea is to have a taint tracking tag added to the unused 30bits of
> bit_field3. I also want to pass on that tag when e.g. appending strings (I'm
> just at the start of the project and this is a nice little test) - can you
> point in the direction of the proper function for that? I added debug
> logging to Heap::AllocateStringFromAscii and Heap::AllocateConsString but
We don't always go into these C++ routines. The generated code can
create strings. Search for string_map in the src/ia32 subdirectory to
see examples.
> those did not trigger. The idea of what I want to get can be grasped in the
> JS example below.
The instance descriptors that Toon describes are for JS Objects.
These are 'real objects' in the JS sense that you can attach arbitrary
properties to.
The strings are primitive objects that you cannot attach arbitrary
properties to. They do not have identity: the == and === operators
just test character-for-character equivalence they don't tell you if
two objects have the same object identity like == and === will on real
JS objects. The strings have their own maps. There are currently a
lot of different maps for different kinds of strings:
7-bit vs. 16 bit
Sequential, cons, slice and external strings
Symbols and non-symbols
That's 16 different string maps.
You probably want to double that by having a tainted and a non-tainted
map for each.
Symbols may be tricky for you. They are internally canonicalized so
that there cannot be two different symbols that have the same sequence
of characters from start to end. When a string is used for a property
name it can be turned into a symbol if there was not already a symbol
with those characters.
So for example:
var key = "x" + tainted_foo; // key is tainted.
hash.key = 0; // key is now a symbol.
// The following now happens in a completely different unrelated part
of the program:
var key2 = "x" + "foo"; // Not tainted.
hash2.key2 = 0; // The symbol "xfoo" is used in hash2, which is tainted.
for (k in hash2) {
do_something(k); // k is tainted, this may fail.
}
Perhaps you just want to forbid using tainted strings for property
names. It's often a bug, due to things like hash collision DOSs or
untrusted sources of the __proto__ string.
Note that all 1-character and most 2-character strings are symbols.
--
Erik Corry, Software Engineer
Google Denmark ApS - Frederiksborggade 20B, 1 sal,
1360 København K - Denmark - CVR nr. 28 86 69 84