REBOL3 tracker
  0.9.12 beta
Ticket #0001197 User: anonymous

Project:



rss
TypeIssue Statustested Date14-Aug-2009 09:57
Versionalpha 77 CategorySecurity Submitted bySunanda
PlatformAll Severityminor Prioritynormal

Summary SELF seems insufficiently protected
Description Not sure if SELF needs protection -- perhaps it can be happily overwritten. But, if it needs it, it needs better than this:

self: 'oops
** Script error: cannot set self - it is protected

Okay so far. But:

set self 'oops
== oops

probe self
make object! [
system: 'oops
oops: 'oops
set: 'oops
probe: make function! [[
{Debug print a molded value and returns that same value.}
value [any-type!]
][
print mold :value
:value
]]
]
Example code
set self 'oops

Assigned ton/a Fixed inalpha 79 Last Update21-Aug-2009 20:41


Comments
(0001487)
meijeru
14-Aug-2009 11:59

Your code does not set self (for that you need to write 'self) but it sets system/context/user (which is the value of self). According to http://www.rebol.net/r3blogs/0232.html , system/contexts is protected, but apparently not via self.
(0001488)
BrianH
14-Aug-2009 13:50

You can't protect the system/contexts/user object itself - it gets modified with every new user script. However, your user scripts can protect the words in system/contexts/user as you see fit.

REBOL can't prevent you from shooting yourself in the foot. The purpose of the security settings is to prevent other people from shooting you in the foot.
(0001489)
meijeru
14-Aug-2009 20:38

How am I to understand the remark that system/contexts/user cannot be protected? It seems to be protected to me...

>> system/contexts/user: 1
** Script error: protected variable - cannot modify: contexts
(0001490)
BrianH
14-Aug-2009 21:38

The word 'user in system/contexts could be protected - the object it refers to (system/contexts/user) can not. SELF in user scripts refers to the same object. You could protect words within that object though.

However, that error you mention is weird: It should be saying "cannot modify: user". The word 'contexts in system should be protected as well, but that is not what you were trying to modify.
(0001491)
Sunanda
14-Aug-2009 22:41

We have some inconsistencies with protecting SELF.
Consider:

CONSOLE SESSION 1:

a: 1 protect 'a
set self 'oops
** Script error: protected value or series - cannot modify

===> so creating and protecting A has protected SELF



Meanwhile, in a separate console

CONSOLE SESSION 2:

set self 'oops
probe self
make object! [
system: 'oops
set: 'oops
oops: 'oops
...
===> SELF has been modified

a: 1 protect 'a

set self 'oops2
probe self
make object! [
system: 'oops
set: 'oops
oops: 'oops
probe: make function! [[
{Debug print a molded value and returns that same value
value [any-type!]
][
print mold :value
:value
]]
a: 1
protect: make native! [[
{Protect a series or a variable from being modified.}
value [word! series! bitset! map! object! module!]
/deep "Protect all sub-series as well"
/words "Block is a list of words"
/hide "Hide variables (avoid binding and lookup)"
]]
oops2: unset!
]

===> Protecting A has apparently silently stopped the modification of words that precede it in SELF.



This all may mean nothing, or it may be a symptom of some part of word handling that needs fine-tuning. Only the man behind the curtain can say for sure.
(0001518)
Carl
20-Aug-2009 06:02

Actually... that all seems correct, because:

    set an-object value


will attempt to set all the fields of the object. So, SET self will do the same.

HOWEVER, if a field of the object is protected, then the SET of the object will fail. (It needs a better error message.) It detects the protection before trying to set any field of the object, so nothing in the object will be set.

In A79, the error message has been changed, and you will now see:

>> set self 'oop
** Script error: protected variable - cannot modify: a
** Where: set
** Near: set self 'oop

I hope that helps.

Date User Field Action Change
21-Aug-2009 20:41 BrianH Status Modified built => tested
20-Aug-2009 06:07 carl Comment : 0001518 Modified -
20-Aug-2009 06:07 carl Comment : 0001518 Modified -
20-Aug-2009 06:06 carl Comment : 0001518 Modified -
20-Aug-2009 06:05 carl Status Modified problem => built
20-Aug-2009 06:05 carl Fixedin Modified => alpha 79
20-Aug-2009 06:04 carl Comment : 0001518 Modified -
20-Aug-2009 06:02 carl Comment : 0001518 Modified -
20-Aug-2009 06:02 carl Comment : 0001518 Added -
14-Aug-2009 22:41 sunanda Comment : 0001491 Added -
14-Aug-2009 21:38 BrianH Comment : 0001490 Added -
14-Aug-2009 20:38 meijeru Comment : 0001489 Added -
14-Aug-2009 13:50 BrianH Comment : 0001488 Added -
14-Aug-2009 13:27 BrianH Type Modified Bug => Issue
14-Aug-2009 13:27 BrianH Status Modified submitted => problem
14-Aug-2009 13:27 BrianH Category Modified Unspecified => Security
14-Aug-2009 13:27 BrianH Description Modified -
14-Aug-2009 12:00 meijeru Comment : 0001487 Modified -
14-Aug-2009 11:59 meijeru Comment : 0001487 Added -
14-Aug-2009 09:57 sunanda Ticket Added -