什么是尘肺病| jeans是什么意思| 犬字旁的字和什么有关| 中药一般什么时候喝最好| 性功能下降吃什么药好| 猫咪拉肚子吃什么药| 献完血吃什么东西补血| img是什么意思| 漂流需要准备什么东西| 舌吻是什么| 男性经常手淫有什么危害| 吃天麻对身体有什么好处| 梁子是什么意思| gg是什么牌子的包包| 12颗珠子的手串什么意思| 不撞南墙不回头是什么意思| 穗是什么意思| 坐骨神经吃什么药效果最好| 火疖子挂什么科| 勃起是什么| 梨花是什么颜色| 禁欲有什么好处| 什么叫流产| hp-是什么意思| 阑尾炎的症状是什么| 大红袍是什么茶类| 12月22日什么星座| 吃什么排铅最快| 质粒是什么| bl和bg是什么意思| 卵巢多囊症是什么原因造成| 长癣是什么原因引起的| 脸上长斑是因为什么原因引起的| 美国为什么不敢打朝鲜| 什么脱口秀| 紫癜是一种什么病严重吗| 什么是数位| 失眠是什么原因导致的| 义五行属什么| 窦炎是什么意思| 狗不能吃什么食物| 血糖高有什么反应| 吃什么代谢快有助于减肥| 云南白药草长什么样| 龙骨是什么| 什么食物含叶酸多| 低压高吃什么中成药| ab血型和o型生的孩子是什么血型| 特种兵是什么兵种| 什么是试管婴儿| 甲状腺看什么门诊| 半夜容易醒是什么原因| 总流鼻血是什么原因| 5月30是什么星座| 黄油是什么做的| 4月10号什么星座| 温暖如初是什么意思| 胃痉挛吃什么药好| 痛经吃什么止疼药| 年轻人手抖是什么原因| 肛门坠胀吃什么药| 什么是横纹肌溶解| 博士生导师是什么级别| 共建是什么意思| 十二指肠溃疡吃什么药| 紫菜和海带有什么区别| 棕色和什么颜色搭配好看| 脚侧面骨头突出叫什么| 做梦梦见大火是什么意思| 结婚纪念日送什么礼物| 心火旺吃什么中药| 耳蜗是什么东西| 目赤什么意思| 四季春是什么茶| 什么蛇最厉害| 高血压一级是什么意思| 吹空调嗓子疼吃什么药| dic是什么意思| 河南属于什么平原| 老人高烧不退是什么原因| 槟榔为什么会上瘾| 唉声叹气是什么意思| 爱而不得是什么意思| 何以是什么意思| 北京生源是什么意思| 什么什么不安| 小孩下面痒用什么药| 腰间盘突出有什么症状| 慢阻肺是什么原因引起的| 海南的海是什么海| 12月6号是什么星座| 三月二十八号是什么星座| 丰胸吃什么| 官官相护是什么意思| 6月19日是什么节日| 今年是什么年庚| 双脚浮肿是什么原因| 9月11号是什么星座| 黑色素缺失吃什么补充最快| 人经常放屁是什么原因| 什么是蜂胶| 搓是什么意思| 阴道流黄色分泌物是什么原因| vae是什么意思| 耳朵挂什么科| 希腊人是什么人种| 相思病是什么意思| 相对而行是什么意思| 故宫为什么叫故宫| 新生儿晚上哭闹不睡觉是什么原因| 头晕什么原因| coupon是什么意思| 手上有红点是什么原因| 开塞露属于什么剂型| mri是什么| 什么偏旁| 嘚是什么意思| 现在什么星座| 二院是什么医院| 天津五行属什么| 1984年属鼠的是什么命| 女为念什么| 什么样的月亮| 解表散热什么意思| 打破伤风挂什么科| 耳道湿疹用什么药| 日本豆腐是什么材料| 368什么意思| 黑皮肤适合穿什么颜色的衣服| brown什么意思| 检查全身挂什么科| 婴儿大便绿色是什么原因| 大海是什么颜色| 辛辣食物指的是什么| 前列腺穿刺是什么意思| 医院查怀孕做什么检查| 四曾念什么| 小腿怕冷是什么原因| 植脂末是什么东西| 离苦得乐什么意思| 12月9日什么星座| 幽门螺杆菌阳性什么意思| 八月一日是什么日子| 风麻疹是什么引起的| 北京为什么叫四九城| 梦见发面是什么意思| 丁香花什么颜色| 脑震荡挂什么科| 右侧中耳乳突炎是什么意思| 手臂酸痛什么原因| 话唠是什么意思| 天丝是什么材质| 喉咙干痒吃什么药| 手指肿胀什么原因| 微商是什么| 望周知是什么意思| 貌合神离是什么意思| 6月12日是什么星座| 藕是什么季节的| 为什么会长痣| 咽炎吃什么消炎药| 什么是催眠| 波菜不能和什么一起吃| 什么是热性水果| 精液发红是什么原因| 老年人流鼻血是什么原因| 胎菊和金银花一起泡水有什么效果| 巾失念什么| 吃饭的时候恶心想吐是什么原因| 什么样的人死后还会出现| 狻猊是什么| 干巴得是什么意思| 上火牙龈肿痛吃什么药| 拜谢是什么意思| 妤字属于五行属什么| 什么时候有胎心胎芽| 五行属木缺什么| 手脚发麻是什么病征兆| ipa啤酒什么意思| 脾虚如何调理吃什么药| 94属什么生肖| 位图是什么意思| 唱过什么歌| 脸油是什么原因导致的| 心跳慢吃什么药| rna是什么| 鸭肉不能和什么一起吃| 口腔溃疡用什么药好得快| 涵养是什么意思| 血红蛋白浓度是什么意思| 腹泻是什么| 意下如何什么意思| 打脚是什么意思| 举牌是什么意思| 血压低吃什么补| 鳑鲏吃什么| 觉悟是什么意思| 什么叫宿根太阳花| 车暴晒有什么影响| 蓄谋已久什么意思| 肚脐上方是什么器官| 打破伤风针挂什么科| 做俯卧撑有什么好处| 驾驶证照片是什么底色| 什么是高利贷| 核桃什么时候吃最好| 叫姑姑是什么关系| 副省长是什么级别| 直肠炎有什么症状| 什么好像什么一样| psy是什么意思| 曹植字什么| 飞行模式是什么意思| 滥竽充数的滥是什么意思| 李耳为什么叫老子| 内分泌失调是什么原因引起的| 处理器是什么意思| 白羊跟什么星座最配| 蓝本是什么意思| 为什么小便是红色的尿| 小孩尿味道很重是什么原因| 头发干燥是什么原因| 花胶是鱼的什么部位| 什么时候打胎对身体伤害最小| 羊肉炖什么好吃| 细菌性阴道病用什么药| 附件是什么| c13呼气试验阳性是什么意思| 什么情况需要打狂犬疫苗| 种草莓是什么意思| 排暖期出血是什么原因| 黑蓝色是什么颜色| 韩国烧酒什么味道| 什么的眼光| 虐狗什么意思| 肺炎是什么原因引起的| 人参不能和什么一起吃| 冷藏是什么意思| 高血脂是什么原因造成的| 转念是什么意思| 缺铁性贫血有什么症状| 黄疸偏高有什么危害| 最好的假牙是什么材质| 什么是周岁| 口腔溃疡缺什么| 屎壳郎长什么样子| press什么意思| 羊头标志是什么车| 为什么低血糖| 1978年属什么生肖| c反应蛋白低说明什么| 半边脸发麻是什么原因| 验孕棒什么时候测最准确| 异性朋友是什么意思| 王代表什么生肖| 格桑花是什么意思| 木林森属于什么档次| 三七粉什么颜色| 活性炭是什么| 头晃动是什么病的前兆| 开屏什么意思| 一叶知秋是什么生肖| 黄瓜和什么一起炒好吃| 美女指什么生肖| 百度
Skip to content

“一带一路”马中友好钢琴交响音乐会在吉隆坡举行

Introduction

百度 其中,2017年7月出台的“成都实施人才优先发展战略行动计划”,提出了给予高层次人才创新创业扶持、鼓励青年人才来蓉落户、发放人才绿卡等12条实实在在的人才红利,被称为“史上最强人才新政”。

This document will provide a starting point for AJAX security and will hopefully be updated and expanded reasonably often to provide more detailed information about specific frameworks and technologies.

Client-Side (JavaScript)

Use innerHTML with extreme caution

Manipulating the Document Object Model (DOM) is common in web applications, especially in monolithic server-side rendering (e.g., PHP, ASP.NET) and AJAX-driven applications. While innerHTML seems like a convenient way to inject HTML content, it poses significant security risks on untrusted-data, particularly cross-site scripting (XSS).

What is innerHTML?

The innerHTML property sets or gets the HTML content of an element, including tags, which the browser parses and renders as part of the DOM. For example, setting innerHTML = "<p>Hello</p>" creates a paragraph element.

Why does innerHTML requires extreme cautions?

Using innerHTML with untrusted data (e.g., from API responses in AJAX) can allow malicious JavaScript to execute in the user’s browser, leading to XSS vulnerabilities. Potential risks include:

  • Stealing user session cookies.
  • Defacing the website.
  • Redirecting users to malicious sites.
  • Performing unauthorized actions (e.g., API calls on behalf of the user).
Vulnerable Example
    document.getElementById('content').innerHTML = data; 
    // DANGER! The server may have returned a payload that executes scripts, for example: <img src=abc onerror=alert('xss!')>.
When is innerHTML acceptable?

The fundamental security rule is to never use innerHTML with untrusted data. However, in limited cases, such as legacy monolithic applications with no viable alternatives, innerHTML may be used cautiously:

  • Static, Hardcoded HTML: For small, fixed HTML snippets that are part of your application’s source code and contain no user input:
document.getElementById('footer').innerHTML = '<p>? 2025 My Company. All rights reserved.</p>';
  • Sanitized HTML: For user-generated HTML (e.g., in rich text editors), sanitize with a library like DOMPurify before using innerHTML:
import DOMPurify from 'dompurify';
const userInput = '<img src=abc onerror=alert("xss")>';
document.getElementById('content').innerHTML = DOMPurify.sanitize(userInput); // Safe, removes malicious code
Alternatives
  • Use Templating Engines (with auto-escaping) for reusable, structured HTML snippets.
  • Use Modern Frameworks (React, Vue, Angular, Svelte) for complex applications. They standardize DOM manipulation, provide reactivity, and inherently handle sanitization for dynamic data. However, developers must avoid unsafe APIs (e.g., dangerouslySetInnerHTML in React, [innerHTML] in Angular) to prevent XSS vulnerabilities.

Use of textContent or innerText for DOM updates (for text-only content)

In AJAX and monolithic server-side rendering applications (e.g., PHP, ASP.NET), dynamic Document Object Model (DOM) updates are common for rendering text-only content from APIs or user inputs.

What is textContent?

The textContent property sets or gets the plain text content of an element. It treats inserted HTML tags as literal text and does not parse them. It is ideal for most text-only updates, such as displaying user comments, etc.

const userInput = '<script>alert("OWASP")</script>';
document.getElementById('content').textContent = userInput; // Displays plain text
What is innerText?

The innerText property sets or gets the visible text content of an element, respecting CSS styling (e.g., ignoring text in display: none elements). It also reflects rendered text formatting, such as line breaks or spacing.

const userInput = 'OWASP'; 
document.getElementById('content').innerText = userInput;
When to Use textContent vs. innerText
  • Use textContent: Use textContent in monolithic applications to safely insert plain text content returned from APIs.
  • Use innerText: Only when CSS visibility or rendered text formatting (e.g. ignoring text in display: none elements) is required.
Note
  • While textContent and innerText are safe for inserting plain text into the DOM, they do not protect against XSS in other contexts such as HTML attributes, JavaScript event handlers, or URLs. Always validate and sanitize untrusted input.
  • Modern Frameworks like React, Vue, Angular, or Svelte automatically update text-only content so there is no need to manually use textContent or innerText.

Don't use eval(), new Function() or other code evaluation tools

eval() function is dangerous, never use it. Needing to use eval() usually indicates a problem in your design.

Encode Data Before Use in an Output Context

When using data to build HTML, script, CSS, XML, JSON, etc., make sure you take into account how that data must be presented in a literal sense to keep its logical meaning.

Data should be properly encoded before used in this manner to prevent injection style issues, and to make sure the logical meaning is preserved.

Check out the OWASP Java Encoder Project.

Don't rely on client logic for security

Don't forget that the user controls the client-side logic. A number of browser plugins are available to set breakpoints, skip code, change values, etc. Never rely on client logic for security.

Don't rely on client business logic

Just like the security one, make sure any interesting business rules/logic is duplicated on the server-side lest a user bypass this logic, leading to unexpected or costly behavior.

Avoid writing serialization code

This is hard and even a small mistake can cause large security issues. There are already a lot of frameworks to provide this functionality.

Refer to the JSON page for more info.

Avoid building XML or JSON dynamically

Just like building HTML or SQL you may cause XML injection bugs, so stay away from this or at least use an encoding library or safe JSON or XML library to make attributes and element data safe.

Never transmit secrets to the client

Anything sent to the client can be read or modified by the user, so keep all that secret stuff on the server please.

Don't perform encryption in client-side code

Use TLS/SSL and encrypt on the server!

Don't perform security impacting logic on client-side

This principle serves as a fail-safe—if a security decision is ambiguous, default to performing it on the server.

Server-Side

Use CSRF Protection

Take a look at the Cross-Site Request Forgery (CSRF) Prevention cheat sheet.

Protect against JSON hijacking for older browsers

Review AngularJS JSON hijacking defense mechanism

See the JSON Vulnerability Protection section of the AngularJS documentation.

Always return JSON with an object on the outside

Always have the outside primitive be an object for JSON strings:

Exploitable:

[{"object": "inside an array"}]

Not exploitable:

{"object": "not inside an array"}

Also not exploitable:

{"result": [{"object": "inside an array"}]}

Avoid writing serialization code server-side

Remember ref vs. value types! Look for an existing library that has been reviewed.

Services can be called by users directly

Even though you only expect your AJAX client-side code to call those services, a malicious user can also call them directly.

Make sure you validate inputs and treat them like they are under user control (because they are!).

Avoid building XML or JSON by hand, use the framework

Use the framework and be safe, do it by hand and have security issues.

Use JSON and XML schema for web services

You need to use a third-party library to validate web services.

颈管细胞有是什么意思 女生发个wink什么意思 红细胞减少是什么原因 2岁打什么疫苗 喜欢是什么
过敏吃什么 阳痿是什么原因造成的 cp是什么意思 原浆酒是什么意思 什么是胰岛素
女性口苦是什么原因引起的 5.29是什么星座 腿困是什么原因 为什么不能下午看病人 乌鸡炖什么好吃
代糖是什么 树叶又什么又什么 93是什么意思 什么食物 病毒性感染是什么原因
孕妇快生的时候有什么征兆hcv9jop7ns9r.cn 什么叫浮小麦hcv9jop5ns1r.cn 立加羽念什么liaochangning.com 练瑜伽有什么好处hcv8jop2ns9r.cn 心率过快吃什么药hcv8jop5ns5r.cn
梦见晒衣服是什么意思jasonfriends.com 吃黑芝麻有什么好处fenrenren.com 六安瓜片属于什么茶0297y7.com 马革裹尸什么意思hcv9jop0ns3r.cn 如何知道自己是什么星座bfb118.com
什么马hcv7jop6ns9r.cn 百无一用是什么意思hcv8jop3ns8r.cn 好整以暇什么意思hcv9jop6ns5r.cn 什么枕头好sscsqa.com 高密度脂蛋白是什么意思hcv8jop2ns5r.cn
6.25什么星座xscnpatent.com 鲱鱼是什么鱼hcv7jop7ns0r.cn 夜游神是什么意思hcv8jop7ns6r.cn 十五岁是什么年华hcv8jop0ns0r.cn 梦到和妈妈吵架是什么意思hcv7jop6ns8r.cn
百度