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

  • Home
  • SEARCH
  • 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 8564549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:13:31+00:00 2026-06-11T17:13:31+00:00

My PHP application has a file controller. Every file download by an authenticated user

  • 0

My PHP application has a file controller. Every file download by an authenticated user should pass through the file controller first.

As a parameter, I’m using the file inode so it can locate the file correctly inside the disk and it can be passed safely through the URL (since it’s only numbers — I don’t have to worry about UTF-8 file names and such in here).

The files are being read from the filesystem, not a database, so the data is as live as possible.

Giving out the inodes of my filesystem is a security threat? Locating files via inodes is a bad practice?

On permission check:

I’m using Codeigniter as a framework. By extending the core controller class and the _remap() method, I’m able to check if the person accessing the file controller is logged in, for every controller call.

If it is (and the role has permissions), then allow the download. If it’s not, then redirect to login.

On same inodes:

I’m not doing a full filesystem scan. I’m listing a directory within the filesystem, divided by uploaders then by operation id (so basically, each folder would have like 10 files, tops, depending on the parameters). The structure is basically:

module/module_id/user_id/files

I’m guessing that there cannot two files with the same inode in the same folder, and if there’s another file in another filesystem (or in the same, I’m not clear if that’s possible), then it’s not in the same folder, ergo, innaccesible with that parameter chain.

For example (supposing we’re wanting to get a file with inode #5243376):

module/1/3/5243376

If there’s another file with inode 5243376, the file must be inside the folders module/1/3/ so it can be downloaded.

I don’t see any other way of getting the same (or another file), because the controller hanldes that.

The code for the hanlder is simple:

// match inode
$dir    = FCPATH . 'files/' . $type . '/' . $id . '/'. $user . '/';
$files  = scandir($dir);

foreach($files as $file) {
    $stat = stat($dir . $file);
    if ($inode == $stat['ino']) {
        $filename = $file;
    }
}

// this need better feedback lol
if (!isset($filename)) {
    die('Not existing');
}

// fullpath to file to be downloaded
$file = FCPATH . 'files/' . $type . '/' . $id . '/'. $user . '/' . $filename;
  • 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-11T17:13:33+00:00Added an answer on June 11, 2026 at 5:13 pm

    There’s nothing really wrong with it. Basic filesystem security still applies even if you’re dealing with inodes only. But you should realize that inodes may not be unique within the OS. They’re only unique within a particular filesystem. If your host system has multiple mounted FSs within your web root, moving a file to a different dir may in fact become a copy+del operation if the move crosses a filesystem boundary. Now your inode is no longer valid, because a new inode was created in the new location.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application on load checks to see if a user has a file in
We are working with a PHP application which has no concept of switch-able themes;
Has anyone seen this error when working with a PHP application out of dynamic
I am using a PHP application I downloaded, and it is half working on
In a PHP application I am using they provide the ability to pull data
I have deployed a PHP application on my tomcat server(Tomcat 6.0).Previously I was using
I am creating a PHP application for my company and I am using about
I building my first cake PHP application, all things configured correctly, but when i
I'm looking to write a basic PHP file caching driver in a PHP application
I have a signup form where I'm validating user input. Here's my controller: <?php

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.