php - Is this ajax behavior normal, security-wise -


it seems i'm failing understand ajax security , it's not helping keep getting contradicting answers questions. did experiment.

i have js code on site1.com located @ http://site1.com/script.js. on server side, makes entry database doesn't return output. when call function site1.com, see entry logged in database expected.

function enterdb(){   $.ajax({     async: false,     url: 'http://site1.com/test?format=json',     type: 'post',     data: { input: '1' },     success: function(resp) {        alert(resp);     }   }); } 

i copied same js js file of othersite.com, located @ http://othersite.com/script.js see myself if log database. did not because don't want people playing ajax urls other external scripts. contradicts of answers read in previous qusetions

this answers matches result got

cross domain banned because of same origin policy.

but same answer said

your javascript making xhr , spoofing one, same , impossible differentiate (though can make harder).

so what's verdict? goal secure ajax urls they're not used external sites api dump data database.

short answer: you not safe against issue mention.

long answer:

given:

  • a — site control
  • b — site else controls
  • charlie — visitor site has credentials

your javascript making xhr , spoofing one, same , impossible differentiate (though can make harder).

this means can't tell difference between charlie visiting , charlie manually constructing http request access urls provide javascript access.

so what's verdict? goal secure ajax urls they're not used external sites api dump data database.

if charlie visits site b, site b can't read data site via charlie's browser (with charlie's credentials).

site b can cause request made site charlie's browser though (e.g. submitting invisible form invisible iframe js), site b cause data inserted. cross site request forgery, there ways defend against this.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -