Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Php Source Code Unveiled In Browser?, is that possible?
mm22
post May 31 2008, 05:42 AM
Post #1


Member [Level 1]
****

Group: [HOSTED]
Posts: 68
Joined: 21-May 08
Member No.: 62,444



I am quite new to PHP and this concern came to my mind after playing around a bit with it...

When PHP is not correctly configured on the web server the source code of a php file we try to access through a browser will be shown instead of the result of the code itself. This will normally not happen when PHP is working properly, but I was just wondering if it could still be possible to see that code if a user wanted to or if something on the server failed.

This would for example expose sensitive information like mysql passwords and so on...

Is anything like that possible and/or likely to happen?

thanks!
Go to the top of the page
 
+Quote Post
Live-Dimension
post May 31 2008, 06:19 AM
Post #2


Advanced Member
*******

Group: [HOSTED]
Posts: 115
Joined: 23-May 08
From: Australia
Member No.: 62,543



Is it possible if the server is not setup right? Yes. Php has extensive logging abilities. You can log to error logs, or display errors straight into pages that are outputted. This displaying of errors is useful in production/development machines only, as the web programmer can easily find out what error it is without consorting to error logs. Of course, this should be disabled in the final version which goes online, as we don't want visitors seeing sensitive data do we? For some reason, I find a lot of web servers don't do this.

In php.ini - I *think* it's display_errors. You'll need to find out yourself, or ask and let someone else answer. Minus this, there isn't a really easy way to simply see the source code. Naturally, if someone was to hack into your ftp account, and steal/download the php files, they'd get the php source.
Go to the top of the page
 
+Quote Post
truefusion
post May 31 2008, 06:57 PM
Post #3


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,916
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528



Normally, if you want someone to view the source code of a PHP file, you just end the PHP file with the extension "phps". Most Apache configurations have it set up like that. It's not necessarily PHP's configuration that deals with the scenario you're talking about, it could just be how the server has its extensions set up. Another reason why a PHP file would output its source code is when PHP itself is not installed.
Go to the top of the page
 
+Quote Post
tracdoor
post Jun 1 2008, 08:26 PM
Post #4


Member [Level 1]
****

Group: [HOSTED]
Posts: 66
Joined: 2-April 08
From: Berkshire, England
Member No.: 60,270



I don't think so, if it did it would probably be the fault of the server.

If you want people to be able to see the source code put the extension to something like .txt or .phps
Go to the top of the page
 
+Quote Post
mm22
post Jun 2 2008, 02:18 AM
Post #5


Member [Level 1]
****

Group: [HOSTED]
Posts: 68
Joined: 21-May 08
Member No.: 62,444



thank you guys for your answers!

so just to wrap it up, it seems like the possibility of unwanted disclosure of php code in browsers is quite remote, unless we want it to happen by explicitly indicating it (for example changing the extension to phps or txt depending on the server configuration)

anyway nothing is impossible and ultimately is up to the server to do a good job and prevent that to happen wink.gif
Go to the top of the page
 
+Quote Post
galexcd
post Jun 2 2008, 03:59 PM
Post #6


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,076
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251



Unfortunately. this exact issue happened to me. Apparently xisto was updating their version of php and for about an hour the php code was not being parsed out. My only suggestion is to hide the sensitive information that you do not want to be revealed in a directory that only php can access and not a client.
Go to the top of the page
 
+Quote Post
coolcat50
post Jun 2 2008, 05:16 PM
Post #7


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



Well, under normal circumstances, the code is not revealed. It is parsed from the server and is not shown in the HTML source. If something fails though, the source could leak out. I would just suggest to make it so that only PHP can read sensitive files, and that the browser cannot access them.
Go to the top of the page
 
+Quote Post
mm22
post Jun 10 2008, 11:44 AM
Post #8


Member [Level 1]
****

Group: [HOSTED]
Posts: 68
Joined: 21-May 08
Member No.: 62,444



QUOTE(coolcat50 @ Jun 3 2008, 01:16 AM) *
Well, under normal circumstances, the code is not revealed. It is parsed from the server and is not shown in the HTML source. If something fails though, the source could leak out. I would just suggest to make it so that only PHP can read sensitive files, and that the browser cannot access them.


QUOTE(galexcd @ Jun 2 2008, 11:59 PM)
My only suggestion is to hide the sensitive information that you do not want to be revealed in a directory that only php can access and not a client.


I think these are very good and simple suggestions to work around the issue wink.gif thanks
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How do you test your php code(80)
  2. Php Clock(7)
  3. Change Permission With Php Code(3)
  4. Just About Completed My Own Message Board Source.(10)
  5. Adapting Html Code Embed To Work On Phpnuke(7)
  6. Dynamic Image / Signature Generator(12)
  7. Wap Source Code Viewer(4)
  8. Good Source For Learning Php(13)
  9. More Dynamic ?id=browsing With Php (associative Array)(1)
  10. Use Bb Code On Your Site!(7)
  11. Some Basic Php Code Snippets For All Levels Of Experience(3)
  12. My Code Doesnt Resize Large Images, Please Help.(2)
  13. Php Education Class (first Code)(0)
  14. How To Make A Random 7 Number Code?(2)
  15. Whats Wrong>?(9)
  1. Awesome Source Code Viewer Script(7)
  2. Html Code Tester. Online Script(15)
  3. I Need Some Proof Reading For My Code Please! [resolved](7)
  4. Will This Code Work(5)
  5. Use Rss In Php Code(3)
  6. Php Code(15)
  7. Php Code Needed(5)
  8. Php Code?(12)
  9. Php Code Needed Iii(10)
  10. Need Some Help In File Browser(8)
  11. Php And Mysql Programming(2)
  12. Malicious Code Injection(3)
  13. Create Table - Mysql Code - Help(1)