Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to mask command line arguments in C shell?

25 views
Skip to first unread message

Jeffrey M. Altbush

unread,
Jan 12, 1995, 1:45:04 PM1/12/95
to
Some time ago, a security issue was discussed in the
comp.databases.oracle newsgroup related to command line arguments
which could be revealed through the ps command in Unix. Many solutions
were discussed and I have implemented the best of those. However,
one problem area still remains and I would appreciate your advice.

Consider this problem: Suppose I choose to use the Oracle program sqlplus
as follows to establish a database session:
% sqlplus altbush/boston
If someone else uses the ps command, my username and password will
be plainly visible in the ps listing. If you generalize this
problem, command line arguments can often contain information you
do not wish to reveal. How do you obscure this information?

Some solutions follows:
1. When issuing a command, have the first argument include a large
number of leading spaces (300 or so). The following is a code
fragment from a C program which constructs a command and then
executes it:
sprintf(cmdstring,
"sqlplus %300s/%s @myscript.sql",
un_str, pw_str);
system(cmdstring);
The result of this is that the command string is longer than
that revealed by the ps command and the sensitive part is
effectively not shown. By nature, this is a hack but it works.

2. In a C program, blank out the arguments which you want to obscure:
strcpy(un_str,argv[1]);
strcpy(pw_str,argv[2]);
sprintf(argv[1],"%*s",strlen(argv[1]),"*");
sprintf(argv[2],"%*s",strlen(argv[2]),"*");
The result of this is very effective. Now, when you do a ps,
the username and password are each replaced by an asterisk. All
other input arguments are shown, but the sensitive bits are
masked. This option is better, as it puts the responsibility for
hiding sensitive data on the function, not the program/person
which invokes it. Further, you are ensured that all invocations
of the function will hide the data.

The problem to be solved: how do you apply the second, more general
solution to the C shell (or any other Unix shell)? I have tried
to change the value of argv[n]. However these changes do not seem
to affect what is displayed from ps.

Thanks for your advice.

Jeffrey Altbush
TASC, Inc, Reading, MA
617-942-2000
jmal...@tasc.com

0 new messages