security - Is it safe to use relative links in website? -


in building website, referencing files (assets, js, css) parent folder via relative links. safe practice? or opening site security issues/risks such directory traversal attack? absolute links safer or cause many more http requests? what's best practice?

there no security risk. directory traversal happens when buggy web server implementation or buggy script incorrectly allows path characters entered in url , server directory structure traversed. example, ".." or "/" characters (or encoded versions).

an example if had url https//www.example.com/readfile.php?file=readme.txt , malicious user change https//www.example.com/readfile.php?file=/etc/passwd if worked vulnerable.

a link in html page same user directly entering url in address bar in case, no risk introduced. relative links more secure in there less risk bugs introduced url parsing code generate absolute links. latest versions of popular web servers secure against attack, , if haven't introduced own scripts contain vulnerability should safe.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -