Note that there are some explanatory texts on larger screens.

plurals
  1. POURL Security in CodeIgniter Application
    primarykey
    data
    text
    <p><strong>Disclaimer</strong>: I'm new to web development.</p> <p><strong>Scenario</strong>: I've built an application using CodeIgniter that would be best described as an event calendar. There is a shared feature in the application that allows you to share your event calendar with another individual. When logged in, a user can travel to the shared page, and choose from a list of those who have shared their event calendars with them. Currently, when a user selects the name of the person who has shared their event calendar with them, the following URI is generated:</p> <pre><code>http://example.com/folder/controller/method/id </code></pre> <p>The <code>id</code> section is the the <code>owner_id</code> in the database of the user who has shared their calendar with the individual.</p> <p><strong>Issue</strong>: It's easy to go change the <code>id</code> section of the URL to another user's <code>owner_id</code> in the database. This allows whoever does so to access the event calendar of an individual who has not authorized the sharing of their event calendar.</p> <p><strong>Question</strong>: What are some methods to resolve this security gap? Please let me know if there is anything else that I need to provide, or explain in a clearer fashion. Thanks in advance for your time and energy.</p> <p><strong>Model</strong>:</p> <pre><code>class Shares_model extends crud_model { public function __construct() { parent::__construct(); $this-&gt;pk = 'id'; $this-&gt;table_name = 'shares'; } public function get($shared_to_user_id) { $this-&gt;db-&gt;where('shared_to_id', $shared_to_user_id); $ids = parent::get_all(); $users = array(); foreach ($ids as $id) { $users[$id-&gt;owner_id]['owner_id'] = $id-&gt;owner_id; $users[$id-&gt;owner_id]['owner_first_name'] = $id-&gt;owner_first_name; $users[$id-&gt;owner_id]['owner_last_name'] = $id-&gt;owner_last_name; } return $users; } } </code></pre> <p><strong>View</strong>:</p> <pre><code>&lt;div class="panel"&gt; &lt;h4&gt;Shared Planners&lt;/h4&gt; &lt;ol&gt; &lt;?php foreach($sharers as $s): ?&gt; &lt;li&gt;&lt;a href="&lt;?php echo base_url('user/shared/view/'.$s['owner_id']) ?&gt;"&gt;&lt;strong&gt;&lt;?php echo $s['owner_first_name']." ".$s['owner_last_name'] ?&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ol&gt; &lt;/div&gt; </code></pre> <p><strong>Controller</strong>:</p> <pre><code>class Shared extends Common_Auth_Controller { private $end_user; public function __construct() { parent::__construct(); $this-&gt;end_user = $this-&gt;ion_auth-&gt;user()-&gt;row(); $data['end_user'] = $this-&gt;end_user; $this-&gt;load-&gt;vars($data); $this-&gt;load-&gt;model('events_model', 'events'); } public function index() { $title['title'] = 'Shared'; $this-&gt;load-&gt;model('shares_model','shares'); $data['sharers'] = $this-&gt;shares-&gt;get($this-&gt;end_user-&gt;id); $this-&gt;load-&gt;view('public/head_view', $title); $this-&gt;load-&gt;view('user/header_view'); $this-&gt;load-&gt;view('user/shared_view', $data); $this-&gt;load-&gt;view('user/footer_view'); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload