as part of a command or query. A) SQL injection B) Request parameter injection //do not do this function dbFn(\PDO $pdo, string $stdId) : IO { return IO::return($pdo) ->map(function ($pdo) use ($stdId) { $stmt = $pdo->query(‘ SELECT student_name, student_id FROM students WHERE student_id = $stdId ’) ... }) } //do not do this either function inputfn() : string { //state monad return State::of(‘php://input’) ->flatMap(‘file_get_contents’); }
B) Avoid ORMs which are non-prepared statement compatible C) Escape query and input parameters D) Use LIMIT in SQL queries to prevent mass data leakage function dbFn(\PDO $pdo, string $stdId) : IO { return IO::return($pdo) ->map(function ($pdo) use ($stdId) { $stmt = $pdo->query(‘ SELECT student_name, student_id FROM students WHERE student_id = :stdId ’); $stmt->bind(‘:stdId’, $stdId, \PDO::PARAM_STR); ... }) } function inputfn() : string { //state monad return State::of(‘php://input’) ->map(‘file_get_contents’) ->flatMap( function ($input) { return array_map( function ($str) { return htmlentities($str, ENT_QUOTES); }, $input ); } ); }
can use credential stuffing and password cracking techniques. A) Well known passwords are generally accepted (admin, password etc) B) Passwords are weakly hashed or stored in plain text C) Knowledge based answers are used for credential recovery
B) Classify data as either processed, transmitted or stored C) Hide sensitive data from viewers D) Use SSL\TLS //Keys.php class Keys { const APP_TOKEN = ‘app token’; const APP_SECRET = ‘app secret’; } //API request function search(API $service, string $param) : IO { return IO::return($param) ->map( function ($param) use ($service) { return $service ->searchFor($param) ->keys(Keys::APP_TOKEN, Keys::APP_SECRET); } ) ... }
B) Disable web server directory listing C) Use Rate limiting APIs D) Never publically cache data served from protected pages E) Domain access control //public API’s only header(‘Access-Control-Allow-Origin: *’); //private APIs only header(‘Access-Control-Allow-Origin: https://your-site’); //caching for private content header(‘Cache-control: no-cache must-revalidate’); //.htaccess file Options -Indexes