do. command. safety. ?

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

do. command. safety. ?

Bob Sneidar via use-livecode
Dear Geniuses

Sometimes.... late at night just before falling asleep I think about the
dangers of the do command.  Is it possible to inject code into this
mechanism through malware?

I do not have enough understanding of operating systems and their processes
...and the livecode engine....to be able to know if its a reasonable
question or not.

Thanks for any input on this.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
Any shell command that can do anything dangerous is typically protected by the host OS. You could not for example install software in a way that would bypass UAC in Windows. You *could* conceivably delete all the files in a folder I suppose, but you couldn't copy files to a protected location. Essentially anything the end user is capable of doing, LC can do, but this is not unique. You can say that about any application. If the IT department has given complete write access to everything to all their users (a common practice I am learning as I interact with our customer IT departments) then it's not up to LC to try to protect themselves from themselves.

HTH
Bob S


> On Mar 30, 2018, at 08:43 , Tom Glod via use-livecode <[hidden email]> wrote:
>
> Dear Geniuses
>
> Sometimes.... late at night just before falling asleep I think about the
> dangers of the do command.  Is it possible to inject code into this
> mechanism through malware?
>
> I do not have enough understanding of operating systems and their processes
> ...and the livecode engine....to be able to know if its a reasonable
> question or not.
>
> Thanks for any input on this.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Using do safely is the same as making database queries safe, or URL requests.

You 'just' need to make sure that any input from outside is sanitized to ensure that it doesn't change the meaning of the expression you are 'doing'.

For example, don't interpolate strings directly in the script using quotes, use a local var instead:

put user input into tVar1
do "put tVar1 into x" -- safe

Rather than

do "put " && quote & user input & quote && "into x" -- not safe

Warmest Regards,

Mark.

Sent from my iPhone

> On 30 Mar 2018, at 16:43, Tom Glod via use-livecode <[hidden email]> wrote:
>
> Dear Geniuses
>
> Sometimes.... late at night just before falling asleep I think about the
> dangers of the do command.  Is it possible to inject code into this
> mechanism through malware?
>
> I do not have enough understanding of operating systems and their processes
> ...and the livecode engine....to be able to know if its a reasonable
> question or not.
>
> Thanks for any input on this.
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
Valid point Bob. Thank You.

Useful info, Thanks Mark..... I was doing it the right way sometimes. the
wrong way other times. thank you.

On Fri, Mar 30, 2018 at 12:02 PM, Mark Waddingham via use-livecode <
[hidden email]> wrote:

> Using do safely is the same as making database queries safe, or URL
> requests.
>
> You 'just' need to make sure that any input from outside is sanitized to
> ensure that it doesn't change the meaning of the expression you are 'doing'.
>
> For example, don't interpolate strings directly in the script using
> quotes, use a local var instead:
>
> put user input into tVar1
> do "put tVar1 into x" -- safe
>
> Rather than
>
> do "put " && quote & user input & quote && "into x" -- not safe
>
> Warmest Regards,
>
> Mark.
>
> Sent from my iPhone
>
> > On 30 Mar 2018, at 16:43, Tom Glod via use-livecode <
> [hidden email]> wrote:
> >
> > Dear Geniuses
> >
> > Sometimes.... late at night just before falling asleep I think about the
> > dangers of the do command.  Is it possible to inject code into this
> > mechanism through malware?
> >
> > I do not have enough understanding of operating systems and their
> processes
> > ...and the livecode engine....to be able to know if its a reasonable
> > question or not.
> >
> > Thanks for any input on this.
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
Ah I saw command in the subject and thought you were talking about shell commands.

Bob S


> On Mar 30, 2018, at 09:49 , Tom Glod via use-livecode <[hidden email]> wrote:
>
> Valid point Bob. Thank You.
>
> Useful info, Thanks Mark..... I was doing it the right way sometimes. the
> wrong way other times. thank you.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
your point still applies about not being responsible that the user has
allowed malware onto their system.

On Fri, Mar 30, 2018 at 12:52 PM, Bob Sneidar via use-livecode <
[hidden email]> wrote:

> Ah I saw command in the subject and thought you were talking about shell
> commands.
>
> Bob S
>
>
> > On Mar 30, 2018, at 09:49 , Tom Glod via use-livecode <
> [hidden email]> wrote:
> >
> > Valid point Bob. Thank You.
> >
> > Useful info, Thanks Mark..... I was doing it the right way sometimes. the
> > wrong way other times. thank you.
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
These look the same to me. Both versions place content into a variable. Is
the difference because of how the engine evaluates the input somehow?

--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On March 30, 2018 11:04:54 AM Mark Waddingham via use-livecode
<[hidden email]> wrote:

> Using do safely is the same as making database queries safe, or URL requests.
>
> You 'just' need to make sure that any input from outside is sanitized to
> ensure that it doesn't change the meaning of the expression you are 'doing'.
>
> For example, don't interpolate strings directly in the script using quotes,
> use a local var instead:
>
> put user input into tVar1
> do "put tVar1 into x" -- safe
>
> Rather than
>
> do "put " && quote & user input & quote && "into x" -- not safe
>
> Warmest Regards,
>
> Mark.
>
> Sent from my iPhone
>
> > On 30 Mar 2018, at 16:43, Tom Glod via use-livecode
> <[hidden email]> wrote:
> >
> > Dear Geniuses
> >
> > Sometimes.... late at night just before falling asleep I think about the
> > dangers of the do command.  Is it possible to inject code into this
> > mechanism through malware?
> >
> > I do not have enough understanding of operating systems and their processes
> > ...and the livecode engine....to be able to know if its a reasonable
> > question or not.
> >
> > Thanks for any input on this.
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
Think about the string that can be constructed in the quoted version - user input could be "; ...;put " where ... is any code you would like...

Sent from my iPhone

> On 30 Mar 2018, at 18:09, J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> These look the same to me. Both versions place content into a variable. Is the difference because of how the engine evaluates the input somehow?
>
> --
> Jacqueline Landman Gay | [hidden email]
> HyperActive Software | http://www.hyperactivesw.com
>> On March 30, 2018 11:04:54 AM Mark Waddingham via use-livecode <[hidden email]> wrote:
>>
>> Using do safely is the same as making database queries safe, or URL requests.
>>
>> You 'just' need to make sure that any input from outside is sanitized to ensure that it doesn't change the meaning of the expression you are 'doing'.
>>
>> For example, don't interpolate strings directly in the script using quotes, use a local var instead:
>>
>> put user input into tVar1
>> do "put tVar1 into x" -- safe
>>
>> Rather than
>>
>> do "put " && quote & user input & quote && "into x" -- not safe
>>
>> Warmest Regards,
>>
>> Mark.
>>
>> Sent from my iPhone
>>
>> > On 30 Mar 2018, at 16:43, Tom Glod via use-livecode <[hidden email]> wrote:
>> >
>> > Dear Geniuses
>> >
>> > Sometimes.... late at night just before falling asleep I think about the
>> > dangers of the do command.  Is it possible to inject code into this
>> > mechanism through malware?
>> >
>> > I do not have enough understanding of operating systems and their processes
>> > ...and the livecode engine....to be able to know if its a reasonable
>> > question or not.
>> >
>> > Thanks for any input on this.
>> > _______________________________________________
>> > use-livecode mailing list
>> > [hidden email]
>> > Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> > http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
Couldn't the same be said about tVar? I suppose you mean that you could check the user input before doing it.

Bob S

> On Mar 30, 2018, at 10:15 , Mark Waddingham via use-livecode <[hidden email]> wrote:
>
> Think about the string that can be constructed in the quoted version - user input could be "; ...;put " where ... is any code you would like...


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Well yes, but as Bob mentioned, wouldn't a variable do the same thing?

   put ";delete hard drive;put " into x
   do x

vs:

   do "put " && quote & ";delete hard drive;put " & quote && "into x"

This actually came up way back in MetaCard where it was pointed out that
the engine was about as secure as it gets as long as you validate all
user input when using "do" or (I think) "value". In the first example
above, input needs to be examined before the "do" command is issued. So
I think there's a line or two missing in there somewhere. ;)


On 3/30/18 12:15 PM, Mark Waddingham via use-livecode wrote:

> Think about the string that can be constructed in the quoted version - user input could be "; ...;put " where ... is any code you would like...
>
> Sent from my iPhone
>
>> On 30 Mar 2018, at 18:09, J. Landman Gay via use-livecode <[hidden email]> wrote:
>>
>> These look the same to me. Both versions place content into a variable. Is the difference because of how the engine evaluates the input somehow?
>>
>> --
>> Jacqueline Landman Gay | [hidden email]
>> HyperActive Software | http://www.hyperactivesw.com
>>> On March 30, 2018 11:04:54 AM Mark Waddingham via use-livecode <[hidden email]> wrote:
>>>
>>> Using do safely is the same as making database queries safe, or URL requests.
>>>
>>> You 'just' need to make sure that any input from outside is sanitized to ensure that it doesn't change the meaning of the expression you are 'doing'.
>>>
>>> For example, don't interpolate strings directly in the script using quotes, use a local var instead:
>>>
>>> put user input into tVar1
>>> do "put tVar1 into x" -- safe
>>>
>>> Rather than
>>>
>>> do "put " && quote & user input & quote && "into x" -- not safe
>>>
>>> Warmest Regards,
>>>
>>> Mark.
>>>
>>> Sent from my iPhone
>>>
>>>> On 30 Mar 2018, at 16:43, Tom Glod via use-livecode <[hidden email]> wrote:
>>>>
>>>> Dear Geniuses
>>>>
>>>> Sometimes.... late at night just before falling asleep I think about the
>>>> dangers of the do command.  Is it possible to inject code into this
>>>> mechanism through malware?
>>>>
>>>> I do not have enough understanding of operating systems and their processes
>>>> ...and the livecode engine....to be able to know if its a reasonable
>>>> question or not.
>>>>
>>>> Thanks for any input on this.
>>>> _______________________________________________


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Tom Glod wrote:

 > Sometimes.... late at night just before falling asleep I think about
 > the dangers of the do command.  Is it possible to inject code into
 > this mechanism through malware?

Mark's discussion handled the security aspect well.

The only thing I could add would be to examine each case and determine
if "do" is even needed at all there.

In addition to the risk of inviting arbitrary code execution, it's
usually slower than any more direct alternative.  And its use is often
dependent on concatenated expressions, making code more cumbersome to
both write and read.

We used to use "do" a lot in HC, where we had to rely on it often to
circumvent limitations with concatenated object references, variables
with names that could not be known in advance, and others.

LC has much more intelligent handling of concatenated object
expressions, and with arrays we can handle any number of variables where
we need the variable name determined on the fly.

In LC "do" is still sometimes useful, but far less often.  I can't
remember the last time I needed to use, probably a couple years ago.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
The user input was indirected through a variable in the safe version - not made part of the do string... That's the critical difference.

The unsafe version allows user input to change the do'd code, the safe version only changes the content of a variable the do string uses.

Warmest Regards,

Mark.

Sent from my iPhone

> On 30 Mar 2018, at 19:24, J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> Well yes, but as Bob mentioned, wouldn't a variable do the same thing?
>
>  put ";delete hard drive;put " into x
>  do x
>
> vs:
>
>  do "put " && quote & ";delete hard drive;put " & quote && "into x"
>
> This actually came up way back in MetaCard where it was pointed out that the engine was about as secure as it gets as long as you validate all user input when using "do" or (I think) "value". In the first example above, input needs to be examined before the "do" command is issued. So I think there's a line or two missing in there somewhere. ;)
>
>
>> On 3/30/18 12:15 PM, Mark Waddingham via use-livecode wrote:
>> Think about the string that can be constructed in the quoted version - user input could be "; ...;put " where ... is any code you would like...
>> Sent from my iPhone
>>> On 30 Mar 2018, at 18:09, J. Landman Gay via use-livecode <[hidden email]> wrote:
>>>
>>> These look the same to me. Both versions place content into a variable. Is the difference because of how the engine evaluates the input somehow?
>>>
>>> --
>>> Jacqueline Landman Gay | [hidden email]
>>> HyperActive Software | http://www.hyperactivesw.com
>>>> On March 30, 2018 11:04:54 AM Mark Waddingham via use-livecode <[hidden email]> wrote:
>>>>
>>>> Using do safely is the same as making database queries safe, or URL requests.
>>>>
>>>> You 'just' need to make sure that any input from outside is sanitized to ensure that it doesn't change the meaning of the expression you are 'doing'.
>>>>
>>>> For example, don't interpolate strings directly in the script using quotes, use a local var instead:
>>>>
>>>> put user input into tVar1
>>>> do "put tVar1 into x" -- safe
>>>>
>>>> Rather than
>>>>
>>>> do "put " && quote & user input & quote && "into x" -- not safe
>>>>
>>>> Warmest Regards,
>>>>
>>>> Mark.
>>>>
>>>> Sent from my iPhone
>>>>
>>>>> On 30 Mar 2018, at 16:43, Tom Glod via use-livecode <[hidden email]> wrote:
>>>>>
>>>>> Dear Geniuses
>>>>>
>>>>> Sometimes.... late at night just before falling asleep I think about the
>>>>> dangers of the do command.  Is it possible to inject code into this
>>>>> mechanism through malware?
>>>>>
>>>>> I do not have enough understanding of operating systems and their processes
>>>>> ...and the livecode engine....to be able to know if its a reasonable
>>>>> question or not.
>>>>>
>>>>> Thanks for any input on this.
>>>>> _______________________________________________
>
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
At the risk of appearing to be obtuse...I tried both versions of the
"do" and got the same results. In each case, the variable was populated
but no code was executed. In a test stack with one field and one button,
I entered ";set the backcolor of btn 1 to blue;put ". In the button
script I tried both versions of your example (substituting "fld 1" for
"user input".) I also tried it without the semicolons and extra "put "
at the end.

In each case the variable x contained "set the backcolor of btn 1 to
blue" and the button did not change color.

I am quite sure you are right, but could you provide an example where
the embedded command would actually execute?

On 3/30/18 7:06 PM, Mark Waddingham via use-livecode wrote:

> The user input was indirected through a variable in the safe version - not made part of the do string... That's the critical difference.
>
> The unsafe version allows user input to change the do'd code, the safe version only changes the content of a variable the do string uses.
>
> Warmest Regards,
>
> Mark.
>
> Sent from my iPhone
>
>> On 30 Mar 2018, at 19:24, J. Landman Gay via use-livecode <[hidden email]> wrote:
>>
>> Well yes, but as Bob mentioned, wouldn't a variable do the same thing?
>>
>>   put ";delete hard drive;put " into x
>>   do x
>>
>> vs:
>>
>>   do "put " && quote & ";delete hard drive;put " & quote && "into x"
>>
>> This actually came up way back in MetaCard where it was pointed out that the engine was about as secure as it gets as long as you validate all user input when using "do" or (I think) "value". In the first example above, input needs to be examined before the "do" command is issued. So I think there's a line or two missing in there somewhere. ;)
>>
>>
>>> On 3/30/18 12:15 PM, Mark Waddingham via use-livecode wrote:
>>> Think about the string that can be constructed in the quoted version - user input could be "; ...;put " where ... is any code you would like...
>>> Sent from my iPhone
>>>> On 30 Mar 2018, at 18:09, J. Landman Gay via use-livecode <[hidden email]> wrote:
>>>>
>>>> These look the same to me. Both versions place content into a variable. Is the difference because of how the engine evaluates the input somehow?
>>>>
>>>> --
>>>> Jacqueline Landman Gay | [hidden email]
>>>> HyperActive Software | http://www.hyperactivesw.com
>>>>> On March 30, 2018 11:04:54 AM Mark Waddingham via use-livecode <[hidden email]> wrote:
>>>>>
>>>>> Using do safely is the same as making database queries safe, or URL requests.
>>>>>
>>>>> You 'just' need to make sure that any input from outside is sanitized to ensure that it doesn't change the meaning of the expression you are 'doing'.
>>>>>
>>>>> For example, don't interpolate strings directly in the script using quotes, use a local var instead:
>>>>>
>>>>> put user input into tVar1
>>>>> do "put tVar1 into x" -- safe
>>>>>
>>>>> Rather than
>>>>>
>>>>> do "put " && quote & user input & quote && "into x" -- not safe
>>>>>
>>>>> Warmest Regards,
>>>>>
>>>>> Mark.
>>>>>
>>>>> Sent from my iPhone
>>>>>
>>>>>> On 30 Mar 2018, at 16:43, Tom Glod via use-livecode <[hidden email]> wrote:
>>>>>>
>>>>>> Dear Geniuses
>>>>>>
>>>>>> Sometimes.... late at night just before falling asleep I think about the
>>>>>> dangers of the do command.  Is it possible to inject code into this
>>>>>> mechanism through malware?
>>>>>>
>>>>>> I do not have enough understanding of operating systems and their processes
>>>>>> ...and the livecode engine....to be able to know if its a reasonable
>>>>>> question or not.
>>>>>>
>>>>>> Thanks for any input on this.
>>>>>> _______________________________________________
>>
>>
>> --
>> Jacqueline Landman Gay         |     [hidden email]
>> HyperActive Software           |     http://www.hyperactivesw.com
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
BTW, I know this works and is dangerous: do <user input>

It's the insertions that don't seem to be affected.

On 3/31/18 2:03 PM, J. Landman Gay via use-livecode wrote:

> At the risk of appearing to be obtuse...I tried both versions of the
> "do" and got the same results. In each case, the variable was populated
> but no code was executed. In a test stack with one field and one button,
> I entered ";set the backcolor of btn 1 to blue;put ". In the button
> script I tried both versions of your example (substituting "fld 1" for
> "user input".) I also tried it without the semicolons and extra "put "
> at the end.
>
> In each case the variable x contained "set the backcolor of btn 1 to
> blue" and the button did not change color.
>
> I am quite sure you are right, but could you provide an example where
> the embedded command would actually execute?
>
> On 3/30/18 7:06 PM, Mark Waddingham via use-livecode wrote:
>> The user input was indirected through a variable in the safe version -
>> not made part of the do string... That's the critical difference.
>>
>> The unsafe version allows user input to change the do'd code, the safe
>> version only changes the content of a variable the do string uses.
>>
>> Warmest Regards,
>>
>> Mark.
>>
>> Sent from my iPhone
>>
>>> On 30 Mar 2018, at 19:24, J. Landman Gay via use-livecode
>>> <[hidden email]> wrote:
>>>
>>> Well yes, but as Bob mentioned, wouldn't a variable do the same thing?
>>>
>>>   put ";delete hard drive;put " into x
>>>   do x
>>>
>>> vs:
>>>
>>>   do "put " && quote & ";delete hard drive;put " & quote && "into x"
>>>
>>> This actually came up way back in MetaCard where it was pointed out
>>> that the engine was about as secure as it gets as long as you
>>> validate all user input when using "do" or (I think) "value". In the
>>> first example above, input needs to be examined before the "do"
>>> command is issued. So I think there's a line or two missing in there
>>> somewhere. ;)
>>>
>>>
>>>> On 3/30/18 12:15 PM, Mark Waddingham via use-livecode wrote:
>>>> Think about the string that can be constructed in the quoted version
>>>> - user input could be "; ...;put " where ... is any code you would
>>>> like...
>>>> Sent from my iPhone
>>>>> On 30 Mar 2018, at 18:09, J. Landman Gay via use-livecode
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> These look the same to me. Both versions place content into a
>>>>> variable. Is the difference because of how the engine evaluates the
>>>>> input somehow?
>>>>>
>>>>> --
>>>>> Jacqueline Landman Gay | [hidden email]
>>>>> HyperActive Software | http://www.hyperactivesw.com
>>>>>> On March 30, 2018 11:04:54 AM Mark Waddingham via use-livecode
>>>>>> <[hidden email]> wrote:
>>>>>>
>>>>>> Using do safely is the same as making database queries safe, or
>>>>>> URL requests.
>>>>>>
>>>>>> You 'just' need to make sure that any input from outside is
>>>>>> sanitized to ensure that it doesn't change the meaning of the
>>>>>> expression you are 'doing'.
>>>>>>
>>>>>> For example, don't interpolate strings directly in the script
>>>>>> using quotes, use a local var instead:
>>>>>>
>>>>>> put user input into tVar1
>>>>>> do "put tVar1 into x" -- safe
>>>>>>
>>>>>> Rather than
>>>>>>
>>>>>> do "put " && quote & user input & quote && "into x" -- not safe
>>>>>>
>>>>>> Warmest Regards,
>>>>>>
>>>>>> Mark.
>>>>>>
>>>>>> Sent from my iPhone
>>>>>>
>>>>>>> On 30 Mar 2018, at 16:43, Tom Glod via use-livecode
>>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> Dear Geniuses
>>>>>>>
>>>>>>> Sometimes.... late at night just before falling asleep I think
>>>>>>> about the
>>>>>>> dangers of the do command.  Is it possible to inject code into this
>>>>>>> mechanism through malware?
>>>>>>>
>>>>>>> I do not have enough understanding of operating systems and their
>>>>>>> processes
>>>>>>> ...and the livecode engine....to be able to know if its a reasonable
>>>>>>> question or not.
>>>>>>>
>>>>>>> Thanks for any input on this.
>>>>>>> _______________________________________________
>>>
>>>
>>> --
>>> Jacqueline Landman Gay         |     [hidden email]
>>> HyperActive Software           |     http://www.hyperactivesw.com
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
On Fri, Mar 30, 2018 at 9:02 AM, Mark Waddingham via use-livecode <
[hidden email]> wrote:

>
> do "put " && quote & user input & quote && "into x" -- not safe
>


Thus,
   do "initiate global thermonuclear war"


:)

Was shazam the statistical package that actually implemented that (only
partially, we hoped!)


--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
The question is exactly what did you type into the field ? It's unclear
whether the quotes in your email are part of the email, or part of the
field content.

Here's a case that definitely shows the difference:

button "Button"

on mouseup
   localtVar, tX
   do"put "&& quote& thetextoffld1& quote&& "into tx"
   put"now tx="&& tX &CRaftermsg
end mouseup

and button "safe"

on mouseup
   localtVar, tX
   putfld1intotVar
   do"put tVar into tX"
   put"now tx="&& tX &CRaftermsg
end mouseup

and into the field I typed

1+2+3" into tt;set the backcolor of btn 1 to blue;put "


Clicking button 'safe' gives

now tx= 1+2+3" into tt;set the backcolor of btn 1 to blue;put "

after the msg box; and repeated clicks there produce extra lines all the
same.

Clicking button 'button' gives

now tx=

in the msgbox, and the button color changes.

So the embedded command within the field is being executed.

-- Alex.



On 31/03/2018 20:03, J. Landman Gay via use-livecode wrote:

> At the risk of appearing to be obtuse...I tried both versions of the
> "do" and got the same results. In each case, the variable was
> populated but no code was executed. In a test stack with one field and
> one button, I entered ";set the backcolor of btn 1 to blue;put ". In
> the button script I tried both versions of your example (substituting
> "fld 1" for "user input".) I also tried it without the semicolons and
> extra "put " at the end.
>
> In each case the variable x contained "set the backcolor of btn 1 to
> blue" and the button did not change color.
>
> I am quite sure you are right, but could you provide an example where
> the embedded command would actually execute?
>
> On 3/30/18 7:06 PM, Mark Waddingham via use-livecode wrote:
>> The user input was indirected through a variable in the safe version
>> - not made part of the do string... That's the critical difference.
>>
>> The unsafe version allows user input to change the do'd code, the
>> safe version only changes the content of a variable the do string uses.
>>
>> Warmest Regards,
>>
>> Mark.
>>
>> Sent from my iPhone
>>
>>> On 30 Mar 2018, at 19:24, J. Landman Gay via use-livecode
>>> <[hidden email]> wrote:
>>>
>>> Well yes, but as Bob mentioned, wouldn't a variable do the same thing?
>>>
>>>   put ";delete hard drive;put " into x
>>>   do x
>>>
>>> vs:
>>>
>>>   do "put " && quote & ";delete hard drive;put " & quote && "into x"
>>>
>>> This actually came up way back in MetaCard where it was pointed out
>>> that the engine was about as secure as it gets as long as you
>>> validate all user input when using "do" or (I think) "value". In the
>>> first example above, input needs to be examined before the "do"
>>> command is issued. So I think there's a line or two missing in there
>>> somewhere. ;)
>>>
>>>
>>>> On 3/30/18 12:15 PM, Mark Waddingham via use-livecode wrote:
>>>> Think about the string that can be constructed in the quoted
>>>> version - user input could be "; ...;put " where ... is any code
>>>> you would like...
>>>> Sent from my iPhone
>>>>> On 30 Mar 2018, at 18:09, J. Landman Gay via use-livecode
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> These look the same to me. Both versions place content into a
>>>>> variable. Is the difference because of how the engine evaluates
>>>>> the input somehow?
>>>>>
>>>>> --
>>>>> Jacqueline Landman Gay | [hidden email]
>>>>> HyperActive Software | http://www.hyperactivesw.com
>>>>>> On March 30, 2018 11:04:54 AM Mark Waddingham via use-livecode
>>>>>> <[hidden email]> wrote:
>>>>>>
>>>>>> Using do safely is the same as making database queries safe, or
>>>>>> URL requests.
>>>>>>
>>>>>> You 'just' need to make sure that any input from outside is
>>>>>> sanitized to ensure that it doesn't change the meaning of the
>>>>>> expression you are 'doing'.
>>>>>>
>>>>>> For example, don't interpolate strings directly in the script
>>>>>> using quotes, use a local var instead:
>>>>>>
>>>>>> put user input into tVar1
>>>>>> do "put tVar1 into x" -- safe
>>>>>>
>>>>>> Rather than
>>>>>>
>>>>>> do "put " && quote & user input & quote && "into x" -- not safe
>>>>>>
>>>>>> Warmest Regards,
>>>>>>
>>>>>> Mark.
>>>>>>
>>>>>> Sent from my iPhone
>>>>>>
>>>>>>> On 30 Mar 2018, at 16:43, Tom Glod via use-livecode
>>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> Dear Geniuses
>>>>>>>
>>>>>>> Sometimes.... late at night just before falling asleep I think
>>>>>>> about the
>>>>>>> dangers of the do command.  Is it possible to inject code into this
>>>>>>> mechanism through malware?
>>>>>>>
>>>>>>> I do not have enough understanding of operating systems and
>>>>>>> their processes
>>>>>>> ...and the livecode engine....to be able to know if its a
>>>>>>> reasonable
>>>>>>> question or not.
>>>>>>>
>>>>>>> Thanks for any input on this.
>>>>>>> _______________________________________________
>>>
>>>
>>> --
>>> Jacqueline Landman Gay         |     [hidden email]
>>> HyperActive Software           | http://www.hyperactivesw.com
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Jacque wrote:
 > could you provide an example where the embedded command would actually
 > execute?

A variant of Mark's example which executes when passed to fooEvil but
not when pass to fooGood:

on mouseUp
    put "into x "&quote&";answer GOTCHA &cr& word 1 of the params #" \
        into tUserInput
    fooGood tUserInput
    fooEvil tUserInput
end mouseUp

on fooGood pUserInput
    do "put pUserInput into x"
end fooGood

on fooEvil pUserInput
    do "put " &quote& pUserInput &quote&" into x"
end fooEvil


--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Thanks for the examples, Alex and Richard. I did understand the
principle behind the caution but I couldn't get any of my tests to
produce bad results. Both your examples do that.

I think the problem was that I wasn't being imaginative enough.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
On 04/01/2018 11:40 AM, J. Landman Gay via use-livecode wrote:
> Thanks for the examples, Alex and Richard. I did understand the
> principle behind the caution but I couldn't get any of my tests to
> produce bad results. Both your examples do that.
>
> I think the problem was that I wasn't being imaginative enough.
>

Yep. That's the problem with security coding - you have to be more
imaginative keeping out of trouble than the imaginative folks who are
looking for ways to cause mischief.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: do. command. safety. ?

Bob Sneidar via use-livecode
So next time I'd better hire one of you guys, looks like. Malice isn't my
strong point. Except maybe for certain distant relatives.

--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On April 1, 2018 5:42:26 PM Mark Wieder via use-livecode
<[hidden email]> wrote:

On 04/01/2018 11:40 AM, J. Landman Gay via use-livecode wrote:
Thanks for the examples, Alex and Richard. I did understand the
principle behind the caution but I couldn't get any of my tests to
produce bad results. Both your examples do that.

I think the problem was that I wasn't being imaginative enough.

Yep. That's the problem with security coding - you have to be more
imaginative keeping out of trouble than the imaginative folks who are
looking for ways to cause mischief.

--
Mark Wieder
[hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
12