Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8807851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:28:12+00:00 2026-06-14T02:28:12+00:00

I want to make an own static file view that returns the file defined

  • 0

I want to make an own static file view that returns the file defined in the GET request. The file must be in an extra directory. The URL must be like /e?s=NAME_OF_FILE. My problem is, hackers can use this like /e?s=/PATH/TO/DATABASE to get any file from the server. I have already a workaround, but i think there are better solutions.

My code:

path = os.path.abspath(os.path.join(script_path, filename))
if path.startswith(script_path):
    # Good
else:
    # Bad

This is for “hidden static files”, that should not be handled by the server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:28:13+00:00Added an answer on June 14, 2026 at 2:28 am

    What you are doing is of not much help. Some things you could do –

    1. In the webserver turn off directory listing so that the ‘hacker’ does not get the list of all files in that directory.
    2. Instead of exposing the actual filename to outside world you could take the filename, generate a MD5 has of this filename, store this mapping somewhere in your servers and expose this MD5 as the filename. So it becomes /e?s=MD5_HASH_OF_FILENAME. What this does is make it extremely difficult for the ‘hacker’ to ‘guess’ the filename. Brute-force does not help as MD5 are not easy to guess. So in effect, only people who have been some how sent this URL will have access to it.
    3. You can expose this static file viewing API to only authenticated users rather than make it public API. You can use @login_required decorator.
    4. Finally, enable HTTPS on your webserver.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can you make the .xla file if you want to create your own
I want to make a static class that would load some settings from XML
Hy! I want to make my own Exception Class, but my problem is that
I want to make my own linkedlist implementatin in c++ using templates. However, I
I want to make my own Start Menu replacement and I am trying to
Hii, I want to make my own snmp server and agent.with my own MIB
I want to allow users to make their own Python mods for my game,
I want make a bash script which returns the position of an element from
We are trying to make all our blocks and pages static so that designer
I want to make a global vector of my own object class called Person.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.