diff --git a/lms/djangoapps/courseware/tests/test_masquerade.py b/lms/djangoapps/courseware/tests/test_masquerade.py
index 39a2a57581..ba36397c00 100644
--- a/lms/djangoapps/courseware/tests/test_masquerade.py
+++ b/lms/djangoapps/courseware/tests/test_masquerade.py
@@ -149,6 +149,18 @@ class MasqueradeTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
self.assertIn(self.problem_display_name, problem_html)
self.assertEqual(show_answer_expected, "Show Answer" in problem_html)
+ def verify_real_user_profile_link(self):
+ """
+ Verifies that the 'Profile' link in the navigation dropdown is pointing
+ to the real user.
+ """
+ content = self.get_courseware_page().content
+ self.assertIn(
+ ''.format(self.test_user.username),
+ content,
+ "Profile link should point to real user",
+ )
+
@attr(shard=1)
class NormalStudentVisibilityTest(MasqueradeTestCase):
@@ -326,6 +338,9 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi
self.update_masquerade(role='student', user_name=self.student_user.username)
self.assertEqual(self.get_progress_detail(), u'2/2')
+ # Verify that the user dropdown links have not changed
+ self.verify_real_user_profile_link()
+
# Temporarily override the student state.
self.submit_answer('Correct', 'Incorrect')
self.assertEqual(self.get_progress_detail(), u'1/2')
diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py
index 8fcb0f89fd..3b3668924b 100644
--- a/lms/djangoapps/courseware/views/index.py
+++ b/lms/djangoapps/courseware/views/index.py
@@ -384,6 +384,7 @@ class CoursewareIndex(View):
'staff_access': self.is_staff,
'studio_url': get_studio_url(self.course, 'course'),
'masquerade': self.masquerade,
+ 'real_user': self.real_user,
'xqa_server': settings.FEATURES.get('XQA_SERVER', "http://your_xqa_server.com"),
'bookmarks_api_url': reverse('bookmarks'),
'language_preference': self._get_language_preference(),
diff --git a/lms/templates/user_dropdown.html b/lms/templates/user_dropdown.html
index aa219ddd5d..7dd31d2585 100644
--- a/lms/templates/user_dropdown.html
+++ b/lms/templates/user_dropdown.html
@@ -2,6 +2,11 @@
<%page expression_filter="h"/>
<%namespace name='static' file='static_content.html'/>
+## This template should not use the target student's details when masquerading, see TNL-4895
+<%
+self.real_user = real_user if real_user != UNDEFINED else user
+%>
+
<%!
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
@@ -14,8 +19,8 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_