-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: xss漏洞修复:Saas层增加Xss转义中间件 #844
Conversation
self.__escape_param_list = [] | ||
super(CheckXssMiddleware, self).__init__(*args, **kwargs) | ||
|
||
def process_view(self, request, view, args, kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 支持豁免
if getattr(view, 'escape_exempt', False):
return None
# if method not match, return
if request.method not in ["....]
return
# check if is json
is_json = False
try:
json.loads(....)
is_json = True
except:
is_json = False
if not is_json:
return
try:
......
except Exception:
logger.exception() # 不要用log.error
|
||
def _transfer(self, _get_value): | ||
if isinstance(_get_value, list): | ||
return [escape_name(_value) for _value in _get_value if isinstance(_value, str)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果不是字符串就被丢弃了? ["a", 1, "b"]
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
理论上, 输入端不处理, 输出端处理.
input_str = input_str.replace(">", "") | ||
input_str = input_str.replace('"', "") | ||
input_str = input_str.replace("'", "") | ||
return input_str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没法证明这个中间件是正确的, 因为没有单侧, 并且即使有, 也无法覆盖到所有输入场景
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
虽然现在都是json, 但是不保证未来不会有其他提交方式; 这个实现过于定制
无法证明中间件正确, 无法覆盖所有场景, 引入风险太高 #796 的处理
|
No description provided.