In California a landlord owes a limited duty to tenants to maintain safety and security. The landlord must take reasonable steps against reasonably foreseeable dangers, including from crime. The exact steps required will depend on the specific circumstances, but will require provision of deadbolt locks at a minimum.
None of the sources I found dealt with a case quoit like the one in the question, but crimes by a tenant's guest against another tenant may impose liability if the landlord knew or should have known that the guest was a danger.
Reasonable forseeability is a key concept here.
Justia's page on "Liability for Criminal Activity" (under "Information for landlords") says:
In addition to being responsible for injuries to your tenants that may be the result of dangerous structural conditions or environmental health hazards on your rental property, you can potentially be liable for injuries arising from the criminal activities of third parties. While this may not seem fair at first, this responsibility falls under your general duty to provide a safe and habitable living environment to your tenants, as well as local and a handful of state laws. Taking some common sense steps, as well as complying with any specific requirements in your jurisdiction, can go a long way toward keeping your tenants safe, and insulating yourself from the significant monetary liability that can arise from injuries to tenants due to criminal acts.
The page "Landlord Liability for Criminal Acts of the Tenant" from Davidovich & Stein, a law firm, says:
Property owners are required by law (to some degree) to protect their tenants from burglary, assailants, as well as other occupants in the rental property. The landlord is also liable for the criminal acts of tenants living in the building along with having a duty to protect the neighborhood from illegal activities. There have been many instances when a property owner was held responsible for his/her occupants dealing drugs and had to face severe legal punishments for allowing the illegal activity to continue. Therefore, all landlords should be vigilant and take adequate measures to limit liability for the crimes committed by their tenants.
The page "Landlords’ Duty To Prevent Crime" by David Tobener, a California lawyer, says:
Landlords have a duty to take reasonable steps to protect tenants from the foreseeable criminal acts of another. CAL. CIV. CODE § 1714. Criminal acts can include conduct such as assault, battery, robbery, murder, rape, drug abuse, and property damage. When a landlord fails to use reasonable care to protect their tenants, they can be held liable for the negligent or intentional criminal conduct of a third party. CACI NO. 1005.
In order to be held liable for a tenant’s injuries, the tenant must show that the landlord knew or should have known about the probability of criminal activity and failed to take reasonable steps to protect the tenant. Ann M. v. Pacific Plaza Shopping Center, 6 Cal. 4th 666 (1993). To determine what steps are reasonable to protect a tenant against foreseeable crime, the court will balance the probability of harm to the tenant with the burden of the duty imposed on the landlord to prevent or mitigate the risk of harm. Vasquez v. Residential Investments, Inc., 118 Cal. App. 4th 269, 280 (2004).
California courts have long established that a landlord “owes a duty of care to its tenants to take reasonable steps to secure the common areas under its control.” Ann M., 6 Cal. 4th at 675. Landlords should conduct reasonable periodic inspections of their properties to discover and remedy any unsafe conditions. CACI NO. 1006.
Properly secured doors that prohibit non-tenant strangers from entering a rental property are essential to keeping tenants safe. California law requires landlords to equip doors that provide an ingress and egress to the common areas with “locking mechanisms that comply with applicable fire and safety codes.” CAL. CIV. CODE § 1941.3. Common areas of multi-family dwelling units include the lobby of a building, stairways, elevators, hallways, shared laundry rooms, shared backyard, and on-site parking areas. Ascertaining what additional reasonable security measures a landlord should take to prevent crime in the common areas of a rental property beyond a locked entry/exit door will depend on the neighborhood it is located and what types of crime are likely to occur. Security measures could include extra lighting, motion sensitive lighting, locked outside security gates at the entrance and exit to the property, and video surveillance and cameras.
It is not enough to show that a neighborhood has a high incidence of crime in order to impose a duty on the landlord to take steps to eliminate or mitigate harm to their tenants. Ann M., 6 Cal. 4th at 678. Instead, the tenant must show there were prior similar criminal acts on the property that put the landlord on notice of a need for security measures. Id. at 679.
Landlords can be found liable for the actions of a tenant’s guest. Valencia v. Michaud, 81 Cal. App. 4th 190 (2000). In Valencia, the court found a landlord was liable for the stabbing of a tenant’s young child by a troublesome, unauthorized guest of another tenant, whom the landlord knew about but did not take any steps to prohibit from the premises.
First Tuesday's page on "Landlord liability and criminal activity" says:
Residential landlords are responsible for the maintenance and security of properties they rent or lease to tenants. But are landlords also required to protect tenants from criminal activity? Do landlords risk liability for failing to screen prospective tenants for a criminal history or to evict tenants who commit crimes?
Landlord duties call for reasonable foreseeability
Consider a landlord who leases a residential property to a tenant. The residential manager suspects the tenant is a member of a local gang engaged in criminal activity, though does not have proof. During their tenancy, a tenant in another unit reports multiple incidents of verbal harassment from the tenant. The landlord does not take action. Later, the tenant is involved in a gun fight on the property with another individual and collaterally shoots a tenant in another unit, injuring them.
The injured tenant seeks compensation from the landlord, claiming the landlord is liable for the their injuries since the landlord was aware of inappropriate behavior by the tenant and did not evict the tenant to ensure the safety of fellow residents.
The landlord claims they are not liable since the tenant’s past conduct was insufficient in its nature to provide the landlord reasonable foreseeability the tenant would engage in gunfire and injure another tenant.
Is the landlord liable for the other tenant’s injuries? No! The California Supreme Court ruled the landlord did not have a duty to evict the offending tenant since their behavior and suspected criminal associations did not create reasonable foreseeability the tenant would engage in gun violence and harm fellow tenants on the property. [Castaneda v. Olsher (2007) 41 C4th 1205]
See also Nolo's "Criminal Acts and Activities: Landlord Liability FAQ