in reply to Security issue and solution for terminal command accessed by public user
Consider if someone enters this as the 'number': 1 foot' 'inches'; rm -rf /; echo '
You could sanitize the input by making sure the number is really a number -- only digits and decimal point, that kind of thing (though that's trickier than it sounds, if you want to allow commas/underscores in long numbers, scientific notation, etc.). You can make the user choose from a selection of unit types, and verify that they selected a valid one from a list (because it's trivial to circumvent browser restrictions on that kind of thing). It would also help to open a pipe to/from units (with no command-line arguments) and pass the values to it in interactive mode, where bad inputs shouldn't be as dangerous as they can be on the command line.
Or you can use one of the conversion modules suggested above. Of course, then you're counting on those modules to handle dangerous inputs properly, so you should probably still sanitize your data as much as possible.
Aaron B.
Available for small or large Perl jobs; see my home node.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Security issue and solution for terminal command accessed by public user
by keenlearner (Acolyte) on Jul 07, 2012 at 05:08 UTC | |
by pemungkah (Priest) on Jul 08, 2012 at 16:43 UTC |