Skip to content
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

Object words that override hidden object words aren't accessible, directly #1140

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Closed
Labels

Comments

@Siskin-Bot
Copy link
Collaborator

Submitted by: BrianH

When you PROTECT/hide a word in an object, appending another word of that name is supposed to create a new binding entry of that name. Then, in theory, subsequent bindings to the object are supposed to access the new field, as if the old field didn't exist. Except they don't: Those overrides are currently inaccessible. Even to APPEND, which can't tell that the field has been overridden and tries to override it again.

I'm not sure that allowing appends of previously hidden words to override the old word for new bindings is a good idea (it would probably break the module security model). However, the current behavior is really bad, or at least awkward and ugly: See the code for details.

This seems like something that needs tweaking.

(First noticed by Sunanda)
; First, the expected behavior
>> o1: make object! [g: 'blah protect/hide 'g]
== make object! [
]
>> o1/g
** Script error: cannot access g in path o1/g
>> o2: make object! [g: 'blah]
== make object! [
    g: 1
]
>> repeat x 10 [extend o1 'g x extend o2 'g x]
== 10

; Now, the tests
>> o1
== make object! [
    g: 1
    g: 2
    g: 3
    g: 4
    g: 5
    g: 6
    g: 7
    g: 8
    g: 9
    g: 10
]  ; what?
>> length? o1
== 11
>> o2
== make object! [
    g: 10
]  ; This is what I expected o1 to look like
>> length? o2
== 1
>> words-of o1
== [g g g g g g g g g g]
>> values-of o1
== [1 2 3 4 5 6 7 8 9 10]
>> o1/g
** Script error: cannot access g in path o1/g
>> in o1 'g
== none
>> select o1 'g
== none
>> do in o1 [g]
== 10  ; what?
>> do in o1 [self/g]
== blah  ; see bug #1139
>> append o1 'h do in o1 [h: self]
== make object! [
    g: 1
    g: 2
    g: 3
    g: 4
    g: 5
    g: 6
    g: 7
    g: 8
    g: 9
    g: 10
    h: make object! [...]
]
>> do in o1 [h/g]
** Script error: cannot access g in path h/g

Imported from: CureCode [ Version: alpha 76 Type: Issue Platform: All Category: Security Reproduce: Always Fixed-in:alpha 79 ]
Imported from: metaeducation#1140

Comments:

Rebolbot commented on Aug 3, 2009:

Submitted by: Carl

This needs some discussion, because APPEND of an existing word is actually a SET not an APPEND.

There are a few possible ways to handle this situation. I've marked this bug as 'problem to discuss it in more detail.


Rebolbot commented on Aug 9, 2009:

Submitted by: Sunanda

Here is an example of a system crash (assertion failure 1207) generated by using this bug as an exploit to poison/overflow system/contexts/user

repeat n 5000 [
 print n
 collect-words words-of system/contexts/user
 foreach w words-of system/contexts/user [protect/hide w]
 ]

I see the failure occurring around iteration 2430....That is not enough words to overflow the word limit (somewhere else said to by around the 450,000 mark).


Rebolbot commented on Aug 19, 2009:

Submitted by: Carl

As mentioned above, APPEND (EXTEND) using an existing word is a SET, not an extension of the object. SET requires a BIND, but we are not allowed to bind to hidden fields, and attempting to do so will throw an error.


Rebolbot commented on Aug 19, 2009:

Submitted by: BrianH

That sounds good. We should do that. The current behavior of APPEND extending the object (as shown in the code) is not good.


Rebolbot mentioned this issue on Jan 12, 2016:
BIND/new does not see hidden words


Rebolbot added the Status.important on Jan 12, 2016


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants