Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
a58f6780
Commit
a58f6780
authored
Jun 24, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(configd) escape shell parameters
parent
ca7c0ffa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
processhandler.py
src/opnsense/service/modules/processhandler.py
+7
-2
No files found.
src/opnsense/service/modules/processhandler.py
View file @
a58f6780
...
@@ -418,15 +418,20 @@ class Action(object):
...
@@ -418,15 +418,20 @@ class Action(object):
# use command execution parameters in action parameter template
# use command execution parameters in action parameter template
# use quotes on parameters to prevent code injection
# use quotes on parameters to prevent code injection
if
script_command
.
count
(
'
%
s'
)
>
len
(
parameters
):
if
script_command
.
count
(
'
%
s'
)
>
len
(
parameters
):
# script command accepts more parameters then given, f
u
ll with empty parameters
# script command accepts more parameters then given, f
i
ll with empty parameters
for
i
in
range
(
script_command
.
count
(
'
%
s'
)
-
len
(
parameters
)):
for
i
in
range
(
script_command
.
count
(
'
%
s'
)
-
len
(
parameters
)):
parameters
.
append
(
""
)
parameters
.
append
(
""
)
elif
len
(
parameters
)
>
script_command
.
count
(
'
%
s'
):
elif
len
(
parameters
)
>
script_command
.
count
(
'
%
s'
):
# parameters then expected, fail execution
# parameters then expected, fail execution
return
'Parameter mismatch'
return
'Parameter mismatch'
# force escape of shell exploitable characters for all user parameters
for
escape_char
in
[
'`'
,
'$'
,
'!'
,
'('
,
')'
,
'|'
]:
for
i
in
range
(
len
(
parameters
[
0
:
script_command
.
count
(
'
%
s'
)])):
parameters
[
i
]
=
parameters
[
i
]
.
replace
(
escape_char
,
'
\\
%
s'
%
escape_char
)
script_command
=
script_command
%
tuple
(
map
(
lambda
x
:
'"'
+
x
.
replace
(
'"'
,
'
\\
"'
)
+
'"'
,
script_command
=
script_command
%
tuple
(
map
(
lambda
x
:
'"'
+
x
.
replace
(
'"'
,
'
\\
"'
)
+
'"'
,
parameters
[
0
:
script_command
.
count
(
'
%
s'
)]))
parameters
[
0
:
script_command
.
count
(
'
%
s'
)]))
if
self
.
type
.
lower
()
==
'script'
:
if
self
.
type
.
lower
()
==
'script'
:
# execute script type command
# execute script type command
try
:
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment