Oldes / Rebol-issues

Issue tracker for https://github.com/oldes/Rebol3
4 stars 0 forks source link

PROTECT /lock option #1141

Open Siskin-Bot opened 4 years ago

Siskin-Bot commented 4 years ago

Submitted by: BrianH

PROTECT/lock would lock the current protected, hidden or unprotected status of its argument. How much of or how deep into its argument it would apply depends on the other options provided - see #1014 for details.

It is important to note that this would also allow you to prevent something that is not protected from being protected, which could be a denial-of-service attack.

>> protect a: [1 2 3]
== [1 2 3]
>> a/1: 5
** error
>> b: [x y z]
== [x y x]
>> protect/lock a
== [1 2 3]
>> protect/lock b
== [x y x]
>> unprotect a
** error
>> protect b
** error

Imported from: CureCode [ Version: alpha 76 Type: Wish Platform: All Category: Security Reproduce: Always Fixed-in:none ] Imported from: https://github.com/rebol/rebol-issues/issues/1141

Comments:


Rebolbot mentioned this issue on Jan 12, 2016: SECURE 'protect setting SYSTEM/MODULES needs access controls, similar to SECURE PROTECT/HIDE returns the value it is meant to hide Loophole to add words to modules after creation -- uses BIND? and SELF


Rebolbot added Type.wish and Status.important on Jan 12, 2016


Oldes commented on Jun 7, 2018:

In these commits I implemented protect/permanently. There is also difference, that unprotect does not throw error on locked values, but silently ignores unprotection.

https://github.com/Oldes/r3/commit/053846baa6119ce087f033450c57f314c244a804 https://github.com/Oldes/r3/commit/829bd7842a53a52770e978be36882589789e1576


Oldes added a commit to Oldes/Rebol3 that referenced this issue on Jun 7, 2018: FEAT/FIX: added missing updated file for previous protect/permanently…


Oldes added a commit to Oldes/Rebol3 that referenced this issue on Jun 7, 2018: FEAT: added /permanently refinement to protect function


Oldes commented 1 month ago

Although it is now possible to permanently protect series (values), words are not protected permanently!

>> o: object [a: 1 protect/lock 'a]
== make object! [
    a: 1
]

>> o/a: 2 
** Script error: protected variable - cannot modify: a

>> unprotect 'o/a
== o/a

>> o/a: 3
== 3 ;<--- should be an error!