অনিরাপদ X509TrustManager
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
OWASP বিভাগ: MASVS-CODE: কোড গুণমান
ওভারভিউ
X509TrustManager
ক্লাস একটি দূরবর্তী সার্ভারের সত্যতা যাচাই করার জন্য দায়ী। এটি সার্ভারের শংসাপত্র যাচাই করে এটি করে।
একটি অ্যান্ড্রয়েড অ্যাপ্লিকেশনে একটি অনিরাপদ X509TrustManager
বাস্তবায়ন হল একটি বাস্তবায়ন যা অ্যাপ্লিকেশনটি যে সার্ভারের সাথে যোগাযোগ করছে তার সত্যতা সঠিকভাবে যাচাই করে না। এটি একজন আক্রমণকারীকে একটি বৈধ সার্ভারের ছদ্মবেশ ধারণ করতে এবং আক্রমণকারীকে সংবেদনশীল ডেটা পাঠানোর জন্য অ্যাপ্লিকেশনটিকে প্রতারণা করতে পারে৷
দুর্বলতা বিদ্যমান কারণ X509TrustManager
ক্লাস ব্যবহার করে, Java/Android সার্ভার যাচাইকরণ সম্পূর্ণ ওভাররাইড করার অনুমতি দেয়। X509TrustManager
ক্লাসে আগ্রহের দুটি ফাংশন রয়েছে: checkServerTrusted()
এবং getAcceptedIssuers()
। এই ফাংশন কলগুলি সমস্ত X.509 সার্টিফিকেট বিশ্বাস করার জন্য কনফিগার করা যেতে পারে। অবশেষে, কাস্টম বৈধতা যুক্তি বাগ বা অসম্পূর্ণ হতে পারে এবং অপ্রত্যাশিত সংযোগের অনুমতি দেয়। এই সমস্ত ক্ষেত্রে, ক্লাসের উদ্দেশ্য বাতিল করা হয়েছে এবং X509TrustManager
আউটপুটের উপর ভিত্তি করে প্রতিষ্ঠিত নেটওয়ার্ক সংযোগ নিরাপদ নয়।
প্রভাব
অনিরাপদ X509TrustManager বাস্তবায়ন দুর্বলতার দিকে নিয়ে যেতে পারে যা শিকার অ্যাপ্লিকেশন থেকে নেটওয়ার্ক ট্র্যাফিকের উপর MitM (ম্যান-ইন-দ্য-মিডল) আক্রমণ করতে ব্যবহার করা যেতে পারে। এই অনিরাপদ কোডটি ব্যবহার করার প্রভাব হল যে এই কোডটি ট্রিগার করা হলে একজন ব্যবহারকারীর অ্যাপ্লিকেশন নেটওয়ার্ক ডেটা নেটওয়ার্ক আক্রমণকারীদের (দূরবর্তী বা স্থানীয়ভাবে) দ্বারা আপস করা যেতে পারে। প্রভাবটি নেটওয়ার্ক ট্র্যাফিকের বিষয়বস্তুর উপর নির্ভর করে যা অসাবধানতাবশত প্রকাশিত হয় (PII, ব্যক্তিগত তথ্য, সংবেদনশীল সেশনের মান, পরিষেবার প্রমাণপত্র ইত্যাদি)।
প্রশমন
কাস্টম TLS/SSL শংসাপত্র বৈধতা কোড ব্যবহার বা প্রয়োগ করার পরিবর্তে সমস্ত উত্পাদন, পরীক্ষা, ডিবাগিং এবং ডেভ স্টেজ সংযোগগুলি সঠিকভাবে পরিচালনা করা হয়েছে তা নিশ্চিত করতে NetworkSecurityConfig.xml কার্যকারিতা ব্যবহার করুন৷ পরীক্ষা এবং ডিবাগ বিল্ডের জন্য একটি স্ব-স্বাক্ষরিত শংসাপত্র ব্যবহার করার প্রয়োজন হলে, একটি কাস্টম X509TrustManager
প্রয়োগ করার পরিবর্তে NetworkSecurityConfig ব্যবহার করার কথা বিবেচনা করুন।
সম্পদ
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 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-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Unsafe X509TrustManager\n\n\u003cbr /\u003e\n\n**OWASP category:** [MASVS-CODE: Code Quality](https://mas.owasp.org/MASVS/10-MASVS-CODE)\n\nOverview\n--------\n\nThe `X509TrustManager` class is responsible for verifying the authenticity of a\nremote server. It does this by validating the server's certificate.\n\nAn insecure `X509TrustManager` implementation in an Android application is an\nimplementation that does not properly verify the authenticity of the server with\nwhich the application is communicating. This can allow an attacker to\nimpersonate a legitimate server and trick the application into sending sensitive\ndata to the attacker.\n\nThe vulnerability exists because using the [`X509TrustManager`](/reference/javax/net/ssl/X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate%5B%5D,%20java.lang.String)) class,\nJava/Android allows the complete overriding of server verification. The\n`X509TrustManager` class has two functions of interest:\n[`checkServerTrusted()`](/reference/javax/net/ssl/X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate%5B%5D,%20java.lang.String)) and [`getAcceptedIssuers()`](/reference/javax/net/ssl/X509TrustManager#getAcceptedIssuers()). These function\ncalls can be configured to trust all X.509 certificates. Finally, custom\nvalidation logic may be buggy or incomplete and permit unexpected connections.\nIn all these cases, the purpose of the class has been negated and the network\nconnection established based on the `X509TrustManager` output is not secure.\n\nImpact\n------\n\nUnsafe X509TrustManager implementations can lead to vulnerabilities which can be\nused to perform MitM (Man-in-the-Middle) attacks on network traffic from the\nvictim application. The impact of exploiting this insecure code is that a user's\napplication network data can be compromised by network attackers (remotely or\nlocally) if this code is triggered. The impact is dependent on the content of\nthe network traffic being inadvertently exposed (PII, private information,\nsensitive session values, service credentials, etc).\n\nMitigations\n-----------\n\nUse the [NetworkSecurityConfig.xml](/training/articles/security-config) functionality to ensure that all\nproduction, testing, debugging, and dev stage connections are properly handled\nrather than using or implementing custom TLS/SSL certificate validation code. If\nusing a self-signed certificate is needed for test and debug builds, consider\nusing NetworkSecurityConfig instead of implementing a custom `X509TrustManager`.\n\nResources\n---------\n\n- [Play Warning docs](https://support.google.com/faqs/answer/6346016)\n- [Documentation to assist configuring the Network security configuration xml file.](/training/articles/security-config)\n- [Developer documentation for the TrustManager class.](/reference/javax/net/ssl/TrustManager)\n- [This check looks for X.509TrustManager implementations whose checkServerTrusted or checkClientTrusted methods do nothing (thus trusting any certificate chain).](https://googlesamples.github.io/android-custom-lint-rules/checks/TrustAllX509TrustManager.md.html)\n- [This check looks for custom X.509TrustManager implementations.](https://googlesamples.github.io/android-custom-lint-rules/checks/CustomX509TrustManager.md.html)\n- \u003chttps://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/X509TrustManagerDetector.java\u003e"]]