473,472 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Secure scripts variables

Hello,
given the following situation:

I have a script which is readable and executable by a user, but not
writable.
The users executes the scripts, it reads in a value and based on this value
it computes a result and stores it in a variable.
Can the user read out the value of this variable? If yes, can he be
prevented to do so?

(It's a ordinary user on a Linux system with access to the python
interpreter.)

(Of course: He could just copy the script to a file he has write access and
modify it to print the result. It's a theoretical situation.)

Thanks,
Florian
Jul 18 '05 #1
4 1429
Florian Lindner wrote:
Hello,
given the following situation:

I have a script which is readable and executable by a user, but not
writable.
The users executes the scripts, it reads in a value and based on this
value it computes a result and stores it in a variable.
Can the user read out the value of this variable?
Yes.
If yes, can he be prevented to do so?
Only if the sensitive part of your script runs under different
user. See thread about storing passwords in a script:

http://groups-beta.google.com/group/...e4c114c5114e92

(It's a ordinary user on a Linux system with access to the python
interpreter.)


If there is a will, there is a way :) I used to run a persistant server
on Solaris as ordinary user. The trick is to create an entry in crontab
that will periodically (every 10 minutes) check if your server is
running, if not, start it up. Note however, after that it's not a good
idea to keep sensitive files in your home directory (like your tax
forms or browsing history), because if you make an error in your server
and it will be hacked, then you risk exposing all your files.
Serge.

Jul 18 '05 #2
Florian Lindner <Fl*************@xgm.de> writes:
I have a script which is readable and executable by a user, but not
writable.
The users executes the scripts, it reads in a value and based on this value
it computes a result and stores it in a variable.
Can the user read out the value of this variable? If yes, can he be
prevented to do so?


I don't really understand the question. The user could, for example,
run the Python interpreter under a debugger, and examine its internal
state step by step during execution.

What you really want is a setuid script. That can do what you want,
but you have to write them very carefully.
Jul 18 '05 #3
Paul Rubin wrote:
Florian Lindner <Fl*************@xgm.de> writes:
I have a script which is readable and executable by a user, but not
writable.
The users executes the scripts, it reads in a value and based on this
value it computes a result and stores it in a variable.
Can the user read out the value of this variable? If yes, can he be
prevented to do so?


I don't really understand the question. The user could, for example,
run the Python interpreter under a debugger, and examine its internal
state step by step during execution.

What you really want is a setuid script. That can do what you want,
but you have to write them very carefully.


AFAIK scripts can't be setuid? Can you tell me what you mean and how to do
it?

Florian
Jul 18 '05 #4
Florian Lindner <Fl*************@xgm.de> writes:
AFAIK scripts can't be setuid? Can you tell me what you mean and how to do
it?


Actually it looks like Linux doesn't support setuid scripts. I
thought the feature had been restored. There is a well-known security
hole but there are workarounds for it and some of the BSD-derived
Unixes implement those. And there is a special hack for Perl that
uses an accessory setuid C program to run setuid Perl scripts--maybe
something like it could be written for Python.

Anyway, the simple workaround is to write a simple C wrapper that
invokes the Python interpreter on your script. Make sure to use a
complete path to specify where your script is. From the "perlsec"
documentation:

#define REAL_PATH "/path/to/script"
main(ac, av)
char **av;
{
execv(REAL_PATH, av);
}

Compile this wrapper into a binary executable and then make it rather
than your script setuid or setgid.

http://supportweb.cs.bham.ac.uk/docu...d/perlsec.html

You have to be very careful writing these scripts since there are all
kinds of errors you can make. Perl's "taint checking" feature helps
catch a lot of those and it would be good if Python had something
similar.
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sandman | last post by:
The subject says it all. I am doing a: I have a perl script in which I am using a ReadParse routine that parses the $ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'} which are two variables passed...
5
by: Max | last post by:
I have a collection of system admin scripts (on Win 2k) that I would like to automate the execution of. However, some of them require the use of logins with admin rights, and would therefore prefer...
9
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
7
by: Seth | last post by:
I have noticed that the id of my session object changes when I switch from a non-secure to a secure connection. What I'm trying to do: I have a cookie that is built on the non-secure side of...
5
by: VB Programmer | last post by:
I often use session variables to store the user's security level, and other important info. How secure are session variables? Can someone decrypt it and get the information? (This would be...
5
by: wolfing1 | last post by:
I'm working on a shopping cart page. In page A (checkout) the user enters their credit card information. On postback, if everything is correct, it sends the user to page B (confirmation). My...
14
by: knal | last post by:
Hi there, I'm looking for a secure login script for a sort-of-community site... (PHP, MySQL, sessions, or maybe something else ... ) I know there are a lot of scripts out there, but none of them...
3
uranuskid
by: uranuskid | last post by:
Hey folks, I was going to include a contact form on my website. Well, in the first place that seemed an easy thing to do with a form that prompts a PHP file validating the input vaiables and using...
3
by: Semnan Web Administrator | last post by:
if the any server don't have the SSL protocols this method can be used ... the key of the cryption is the optional and will be change. for example can be a hash of the client HTTP_USER_AGENT...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.