ทดสอบและแก้ไขข้อบกพร่องของฟีเจอร์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หมวดหมู่ OWASP: MASVS-CODE: คุณภาพของโค้ด
ภาพรวม
การเผยแพร่บิลด์เวอร์ชันที่ใช้งานจริงซึ่งมีฟีเจอร์การทดสอบหรือการแก้ไขข้อบกพร่องอาจ
ส่งผลเสียต่อท่าทีด้านความปลอดภัยของแอปพลิเคชัน ฟังก์ชันการทำงานเหล่านี้
ใช้เพื่อช่วยนักพัฒนาแอปในการค้นหาและระบุข้อบกพร่องภายใน Use Case ของแอปพลิเคชันที่ต้องการ
ก่อนหรือหลังการเปิดตัวเวอร์ชันใหม่ และไม่ควร
เข้าถึงได้แบบสาธารณะ
ตัวอย่างฟีเจอร์การทดสอบ/ การแก้ไขข้อบกพร่อง ได้แก่
- เมนูที่ซ่อน
- ตัวเลือกในการเปิดใช้บันทึกการแก้ไขข้อบกพร่อง
- ตัวเลือกในการแก้ไขขั้นตอนการสมัคร
- ตัวเลือกในการหลีกเลี่ยงกระบวนการชำระเงินหรือการสมัครใช้บริการ
- ตัวเลือกในการหลีกเลี่ยงการตรวจสอบสิทธิ์
- การทดสอบสำหรับกิจกรรมเฉพาะแอปพลิเคชัน
ผู้ใช้ที่เป็นอันตรายสามารถใช้ประโยชน์จากทั้งหมดที่กล่าวมาเพื่อเปลี่ยนโฟลว์ที่ตั้งใจไว้ของแอปพลิเคชันหรือดึงข้อมูลระบบเพื่อปรับแต่งการโจมตีเพิ่มเติม
ความเสี่ยงที่เกิดจากการปล่อยให้ฟีเจอร์การทดสอบหรือการแก้ไขข้อบกพร่องที่เปิดเผยไว้อาจแตกต่างกัน
ตามการดำเนินการที่เชื่อมโยงกับความสามารถในการแก้ไขข้อบกพร่องเอง
อีกจุดหนึ่งที่แอปพลิเคชันมีความเสี่ยงคือแอตทริบิวต์ android:debuggable
ซึ่งตั้งค่าไว้ในองค์ประกอบ AndroidManifest.xml <application>
ดังที่รายงานไว้ในบทความandroid:debuggable
การติดตั้งใช้งานแอปพลิเคชันที่ใช้งานจริงโดยตั้งค่าดังกล่าวข้างต้นจะอนุญาตให้
ผู้ใช้ที่เป็นอันตรายเข้าถึงทรัพยากรของผู้ดูแลระบบซึ่งปกติแล้ว
จะเข้าถึงไม่ได้
ผลกระทบ
ผู้ใช้ที่เป็นอันตรายซึ่งโต้ตอบกับฟีเจอร์การทดสอบหรือการแก้ไขข้อบกพร่องในบิลด์ที่ใช้งานจริงอาจทำให้เกิดผลลัพธ์ที่ไม่คาดคิด ผลกระทบของการดำเนินการใดๆ จะเชื่อมโยงโดยตรงกับสิทธิ์ที่กำหนดให้กับฟีเจอร์ ยิ่งมี
สิทธิ์มากเท่าใด การโจมตีที่ใช้งานอยู่ก็ยิ่งส่งผลกระทบมากขึ้นเท่านั้น ฟังก์ชันดังกล่าวภายในแอปพลิเคชันสามารถใช้เพื่อหลีกเลี่ยงการป้องกันหลายอย่าง ข้ามเพย์วอลล์ ดึงข้อมูลที่เกี่ยวข้องกับระบบหรือผู้ใช้ หรือทริกเกอร์กิจกรรมการทดสอบ
การลดปัญหา
หลีกเลี่ยงการใช้คอมโพเนนต์การแก้ไขข้อบกพร่อง
ไม่ควรนำฟังก์ชันการทดสอบหรือการแก้ไขข้อบกพร่องไปใช้ภายในคอมโพเนนต์ของแอปพลิเคชันเวอร์ชันที่ใช้งานจริง เช่น กิจกรรม ตัวรับสัญญาณออกอากาศ บริการ หรือผู้ให้บริการเนื้อหา เนื่องจากหากมีการส่งออก คอมโพเนนต์เหล่านี้จะเรียกใช้ได้โดยกระบวนการอื่นๆ ในอุปกรณ์
การตั้งค่าคอมโพเนนต์การแก้ไขข้อบกพร่องเป็นไม่ได้ส่งออก
(android:exported="false") ไม่ถือเป็นการป้องกันที่ถูกต้องสำหรับความสามารถ เนื่องจากอุปกรณ์ที่รูทแล้วยังคงเรียกใช้ผ่านเครื่องมือ Android Debug Bridge (ADB) ได้ หากเปิดใช้ตัวเลือกการแก้ไขข้อบกพร่อง
จำกัดฟีเจอร์การแก้ไขข้อบกพร่องหรือการทดสอบไว้เฉพาะบิลด์เวอร์ชันทดสอบ
การเรียกใช้ฟังก์ชันทดสอบหรือแก้ไขข้อบกพร่องใดๆ ภายในแอปพลิเคชันควร
จำกัดเฉพาะชุดการสร้างเวอร์ชัน Staging ที่จำกัดเพื่อให้เฉพาะนักพัฒนาแอปเท่านั้นที่
แก้ไขข้อบกพร่องหรือทดสอบฟีเจอร์ของแอปพลิเคชันในสภาพแวดล้อมที่มีการควบคุม
ซึ่งทำได้โดยการสร้างการทดสอบเฉพาะหรือการสร้างการแก้ไขข้อบกพร่องของ
แอปพลิเคชัน และการทดสอบแบบมีเครื่องควบคุมขั้นสูงสำหรับแอปพลิเคชันนั้น เพื่อให้มั่นใจว่าฟีเจอร์การทดสอบหรือการแก้ไขข้อบกพร่องจะทำงานในเวอร์ชันที่แยกต่างหาก
ใช้การทดสอบ UI อัตโนมัติ
เมื่อทำการทดสอบในแอปพลิเคชัน ให้เลือกใช้การทดสอบ UI อัตโนมัติเนื่องจาก
ทำซ้ำได้ ดำเนินการในสภาพแวดล้อมที่แยกต่างหากได้ และไม่เกิด
ข้อผิดพลาดจากมนุษย์
แหล่งข้อมูล
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Test and debug features\n\n\u003cbr /\u003e\n\n**OWASP category:** [MASVS-CODE: Code Quality](https://mas.owasp.org/MASVS/10-MASVS-CODE)\n\n\nOverview\n--------\n\nReleasing production builds that include Testing or Debug features can\nnegatively impact the security posture of the application. These functionalities\nare used to help developers discover and identify bugs within intended\napplication use cases prior to, or after a new version release, and shouldn't\nbe publicly accessible.\n\nExamples of Testing/ Debug features are:\n\n- Hidden menus\n- Options to enable debug logs\n- Options to alter application flow\n- Options to circumvent payment or subscription processes\n- Options to circumvent authentication\n- Tests for application-specific activities\n\nAll the preceding can be leveraged by a malicious user in order to alter the\napplication's intended flow or retrieve system information to tailor further\nattacks.\n\nThe risk introduced by leaving exposed Testing or Debug features may vary\naccording to the action associated with the debug capabilities itself.\n\nAnother area of risk for the application is the attribute **android:debuggable**\nset within the AndroidManifest.xml element **`\u003capplication\u003e`** . As reported in\nthe [**android:debuggable**](/topic/security/risks/android-debuggable) article,\ndeploying a production application with the aforementioned value set, allows\nmalicious users to access administrative resources that are otherwise\ninaccessible.\n\nImpact\n------\n\nA malicious user interacting with a Testing or Debug feature in a production\nbuild can lead to unexpected results. The impact of any action is directly\nconnected with the permissions assigned to the feature. The higher the\npermissions, the higher the impact that an active exploitation can have. Such\nfunctionalities within an application can be used to circumvent a number of\nprotections, bypass paywalls, retrieve system or user related information, or\ntrigger testing activities.\n\nMitigations\n-----------\n\n### Avoid using debug components\n\nTest or debug functionalities should never be implemented within production\napplication components such as activities, broadcast receivers, services or\ncontent providers since, if exported, can be run by any other process on the\ndevice.\nSetting the debug component as not exported\n([**android:exported=\"false\"**](/topic/security/risks/android-exported)) does\nnot constitute a valid protection for the capabilities since any rooted device\ncan still execute it through the Android Debug Bridge (ADB) tool if the debug\noption is enabled.\n\n### Limit debug or test features to staging builds\n\nThe execution of any test or debug function within applications should be\nlimited only to a restricted set of Staging builds to allow only developers to\ndebug or test application's features in a controlled environment.\nThis can be obtained by creating a dedicated test or debug build of the\napplication and advanced instrumented tests for it in order to ensure that any\ntest or debug feature is run on an isolated version.\n\n### Implement automated UI tests\n\nWhen running tests on an application, opt for automated UI tests since they are\nrepeatable, can be executed in a separated environment and are not prone to\nhuman errors.\n\nResources\n---------\n\n- [Dev guidance on advanced testing setups](/studio/test/advanced-test-setup)\n- [Dev guidance on automating UI tests](/training/testing/instrumented-tests/ui-tests)\n- [android:debuggable](/topic/security/risks/android-debuggable)\n- [android:exported](/topic/security/risks/android-exported)\n- [Debuggable Apps in Android Market](https://labs.withsecure.com/publications/debuggable-apps-in-android-market)\n- [Can debug code cause security vulnerabilities?](https://www.coderskitchen.com/an-debug-code-cause-security-vulnerabilities/)"]]